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

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

No files matched your search

@@ -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)
+6 -1
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)
+1 -1
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
+1 -1
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