Skip to content
Snippets Groups Projects
Commit 26678d8e authored by Patricio Cano's avatar Patricio Cano
Browse files

Fix race condition that can be triggered if the token expires right after we...

Fix race condition that can be triggered if the token expires right after we retrieve it, but before we can set the new expiry time.
parent 33d1f590
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -20,13 +20,8 @@ module Gitlab
def token
Gitlab::Redis.with do |redis|
token = redis.get(redis_key)
if token
redis.expire(redis_key, EXPIRY_TIME)
else
token = Devise.friendly_token(TOKEN_LENGTH)
redis.set(redis_key, token, ex: EXPIRY_TIME)
end
token ||= Devise.friendly_token(TOKEN_LENGTH)
redis.set(redis_key, token, ex: EXPIRY_TIME)
 
token
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment