mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
bug #1011: Update user_pool_cache in Sunstone when logging
This commit is contained in:
parent
e3d1ce2cd3
commit
dfb7efc4cf
@ -44,8 +44,11 @@ class CloudAuth
|
||||
def initialize(conf)
|
||||
@conf = conf
|
||||
|
||||
# @token_expiration_delta: Number of seconds that will be used
|
||||
# the same timestamp for the token generation
|
||||
# @token_expiration_time: Current timestamp to be used in tokens.
|
||||
@token_expiration_delta = @conf[:token_expiration_delta] || EXPIRE_DELTA
|
||||
@token_expiration_time = Time.now.to_i + @token_expiration_delta
|
||||
@token_expiration_time = Time.now.to_i + @token_expiration_delta
|
||||
|
||||
if AUTH_MODULES.include?(@conf[:auth])
|
||||
require 'CloudAuth/' + AUTH_MODULES[@conf[:auth]]
|
||||
@ -78,14 +81,23 @@ class CloudAuth
|
||||
Client.new(token,@conf[:one_xmlrpc])
|
||||
end
|
||||
|
||||
def update_userpool_cache
|
||||
@user_pool = OpenNebula::UserPool.new(client)
|
||||
|
||||
rc = @user_pool.info
|
||||
if OpenNebula.is_error?(rc)
|
||||
raise rc.message
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def expiration_time
|
||||
time_now = Time.now.to_i
|
||||
|
||||
if time_now > @token_expiration_time - EXPIRE_MARGIN
|
||||
update_userpool_cache
|
||||
@token_expiration_time = time_now + @token_expiration_delta
|
||||
update_userpool_cache
|
||||
end
|
||||
|
||||
@token_expiration_time
|
||||
@ -97,15 +109,6 @@ class CloudAuth
|
||||
@user_pool
|
||||
end
|
||||
|
||||
def update_userpool_cache
|
||||
@user_pool = OpenNebula::UserPool.new(client)
|
||||
|
||||
rc = @user_pool.info
|
||||
if OpenNebula.is_error?(rc)
|
||||
raise rc.message
|
||||
end
|
||||
end
|
||||
|
||||
def get_password(username, non_public_user=false)
|
||||
if non_public_user == true
|
||||
xp="USER[NAME=\"#{username}\" and AUTH_DRIVER!=\"public\"]/PASSWORD"
|
||||
|
@ -89,6 +89,7 @@ helpers do
|
||||
|
||||
def build_session
|
||||
begin
|
||||
settings.cloud_auth.update_userpool_cache
|
||||
result = settings.cloud_auth.auth(request.env, params)
|
||||
rescue Exception => e
|
||||
error 500, e.message
|
||||
|
Loading…
x
Reference in New Issue
Block a user