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.
This commit is contained in:
parent
33d1f5904c
commit
26678d8ea3
1 changed files with 2 additions and 7 deletions
|
@ -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)
|
||||
token ||= Devise.friendly_token(TOKEN_LENGTH)
|
||||
redis.set(redis_key, token, ex: EXPIRY_TIME)
|
||||
end
|
||||
|
||||
token
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue