1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-15 05:57:23 +03:00

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

This commit is contained in:
Alejandro Huertas Herrero 2022-02-17 15:54:41 +01:00 committed by GitHub
parent 7f719598bd
commit cd8fe575a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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