From cbc622f8b56560593d2b4bb57e71bd04a5b9c520 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 21 Mar 2012 17:18:15 +0100 Subject: [PATCH] bug #1142: Check user driver in CloudAuth --- src/cloud/common/CloudAuth.rb | 6 +++--- src/cloud/common/CloudAuth/EC2CloudAuth.rb | 2 +- src/cloud/common/CloudAuth/OCCICloudAuth.rb | 2 +- src/cloud/common/CloudAuth/OpenNebulaCloudAuth.rb | 4 ++-- src/cloud/common/CloudAuth/SunstoneCloudAuth.rb | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cloud/common/CloudAuth.rb b/src/cloud/common/CloudAuth.rb index 203b7cd928..d33a1a9f6a 100644 --- a/src/cloud/common/CloudAuth.rb +++ b/src/cloud/common/CloudAuth.rb @@ -118,9 +118,9 @@ class CloudAuth @user_pool end - def get_password(username, non_public_user=false) - if non_public_user == true - xp="USER[NAME=\"#{username}\" and AUTH_DRIVER!=\"public\"]/PASSWORD" + def get_password(username, driver=nil) + if driver + xp="USER[NAME=\"#{username}\" and AUTH_DRIVER=\"#{driver}\"]/PASSWORD" else xp="USER[NAME=\"#{username}\"]/PASSWORD" end diff --git a/src/cloud/common/CloudAuth/EC2CloudAuth.rb b/src/cloud/common/CloudAuth/EC2CloudAuth.rb index 38afacd64f..9f76421023 100644 --- a/src/cloud/common/CloudAuth/EC2CloudAuth.rb +++ b/src/cloud/common/CloudAuth/EC2CloudAuth.rb @@ -17,7 +17,7 @@ module EC2CloudAuth def do_auth(env, params={}) username = params['AWSAccessKeyId'] - one_pass = get_password(username) + one_pass = get_password(username, 'core') return nil unless one_pass signature = case params['SignatureVersion'] diff --git a/src/cloud/common/CloudAuth/OCCICloudAuth.rb b/src/cloud/common/CloudAuth/OCCICloudAuth.rb index 69831163ac..5dff6ec0f7 100644 --- a/src/cloud/common/CloudAuth/OCCICloudAuth.rb +++ b/src/cloud/common/CloudAuth/OCCICloudAuth.rb @@ -21,7 +21,7 @@ module OCCICloudAuth if auth.provided? && auth.basic? username, password = auth.credentials - one_pass = get_password(username) + one_pass = get_password(username, 'core') if one_pass && one_pass == password return username diff --git a/src/cloud/common/CloudAuth/OpenNebulaCloudAuth.rb b/src/cloud/common/CloudAuth/OpenNebulaCloudAuth.rb index d29acfee05..bcf54ea99e 100644 --- a/src/cloud/common/CloudAuth/OpenNebulaCloudAuth.rb +++ b/src/cloud/common/CloudAuth/OpenNebulaCloudAuth.rb @@ -14,7 +14,7 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -module CoreCloudAuth +module OpenNebulaCloudAuth def do_auth(env, params={}) auth = Rack::Auth::Basic::Request.new(env) @@ -26,7 +26,7 @@ module CoreCloudAuth rc = user.info if OpenNebula.is_error?(rc) - logger.error { "User #{username} could not be authenticated"} + logger.error { "User #{username} could not be authenticated" } logger.error { rc.message } return nil end diff --git a/src/cloud/common/CloudAuth/SunstoneCloudAuth.rb b/src/cloud/common/CloudAuth/SunstoneCloudAuth.rb index ef3cf0f2e3..1ac866ef6d 100644 --- a/src/cloud/common/CloudAuth/SunstoneCloudAuth.rb +++ b/src/cloud/common/CloudAuth/SunstoneCloudAuth.rb @@ -21,7 +21,7 @@ module SunstoneCloudAuth if auth.provided? && auth.basic? username, password = auth.credentials - one_pass = get_password(username, true) + one_pass = get_password(username, 'core') if one_pass && one_pass == Digest::SHA1.hexdigest(password) return username