Skip to content

Instantly share code, notes, and snippets.

Last active Dec 12, 2015
What would you like to do?
OpenNebula -- fix for X.509 authn username lookup in src/cloud/common/CloudAuth.rb
# 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)

This comment has been minimized.

Copy link
Owner Author

@arax arax commented Feb 13, 2013

This method is located in $ONE_LOCATION/lib/ruby/cloud/CloudAuth.rb when OpenNebula is installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment