Last active
December 12, 2015 05:29
-
-
Save arax/4722445 to your computer and use it in GitHub Desktop.
OpenNebula -- fix for X.509 authn username lookup in src/cloud/common/CloudAuth.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gets the username associated with a password | |
# password:: _String_ the password | |
# [return] _Hash_ with the username | |
def get_username(password) | |
xpath = "USER[PASSWORD=\"#{password}\"]/NAME" | |
username = retrieve_from_userpool(xpath) | |
# No exact match, trying to match password with each | |
# of the pipe-separated DNs stored in USER/PASSWORD | |
if username.nil? | |
@lock.synchronize { | |
@user_pool.each { |user| | |
return user["NAME"] if user["AUTH_DRIVER"] == "x509" && user["PASSWORD"].split('|').include?(password) | |
} | |
} | |
end | |
username | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This method is located in $ONE_LOCATION/lib/ruby/cloud/CloudAuth.rb when OpenNebula is installed.