1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-19 06:50:07 +03:00

feature #931: Update CloudAuth classes to use new server drivers

This commit is contained in:
Daniel Molina 2011-10-21 18:37:41 +02:00
parent 7a44026d66
commit ef302dcbb5
4 changed files with 10 additions and 4 deletions

View File

@ -60,7 +60,8 @@ class ServerCipherAuth
# Generates a login token in the form:
# - server_user:target_user:time_expires
# The token is then encrypted with the contents of one_auth
def login_token(target_user)
def login_token(target_user=nil)
target_user ||= @server_user
token_txt = "#{@server_user}:#{target_user}:#{Time.now.to_i + EXPIRE}"
token = encrypt(token_txt)

View File

@ -14,6 +14,8 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
require 'server_cipher_auth'
class CloudAuth
AUTH_MODULES = {
"basic" => 'BasicCloudAuth',
@ -32,12 +34,15 @@ class CloudAuth
else
raise "Auth module not specified"
end
@server_auth = ServerCipherAuth.new
end
protected
def get_password(username)
@oneadmin_client ||= OpenNebula::Client.new(nil, @conf[:one_xmlrpc])
token = @server_auth.login_token
@oneadmin_client ||= OpenNebula::Client.new(token, @conf[:one_xmlrpc])
if @user_pool.nil?
@user_pool ||= OpenNebula::UserPool.new(@oneadmin_client)

View File

@ -24,7 +24,7 @@ module BasicCloudAuth
one_pass = get_password(username)
if one_pass && one_pass == Digest::SHA1.hexdigest(password)
@token = "#{username}:#{password}"
@token = @server_auth.login_token(username)
@client = Client.new(@token, @conf[:one_xmlrpc])
return nil
else

View File

@ -36,7 +36,7 @@ module EC2CloudAuth
end
end
@token = "#{username}:#{one_pass}"
@token = @server_auth.login_token(username)
@client = Client.new(@token, @conf[:one_xmlrpc])
return nil
end