1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

F #5046: make EXPIRE_DELTA/MARGIN configurable (#1784)

(cherry picked from commit cd8fe575a42ca25377f6f38156aac1d46082da16)
This commit is contained in:
Alejandro Huertas Herrero 2022-02-17 15:54:41 +01:00 committed by Ruben S. Montero
parent 267f7d27a8
commit eb1927750d
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87

View File

@ -56,7 +56,26 @@ class CloudAuth
@lock = Mutex.new
@token_expiration_time = Time.now.to_i + EXPIRE_DELTA
# Read configuration attributes
if conf[:expire_delta]
@expire_delta = conf[:expire_delta]
else
@expire_delta = EXPIRE_DELTA
end
if conf[:expire_margin]
@expire_margin = conf[:expire_margin]
else
@expire_margin = EXPIRE_MARGIN
end
# If user set wrong parameters, use defaults to avoid auth issues
if @expire_delta < @expire_margin
@expire_delta = EXPIRE_DELTA
@expire_margin = EXPIRE_MARGI
end
@token_expiration_time = Time.now.to_i + @expire_delta
@upool_expiration_time = 0
@conf[:use_user_pool_cache] = true
@ -96,8 +115,8 @@ class CloudAuth
expiration_time = @lock.synchronize {
time_now = Time.now.to_i
if time_now > @token_expiration_time - EXPIRE_MARGIN
@token_expiration_time = time_now + EXPIRE_DELTA
if time_now > @token_expiration_time - @expire_margin
@token_expiration_time = time_now + @expire_delta
end
@token_expiration_time