Skip to content

Instantly share code, notes, and snippets.

@arax
Last active December 12, 2015 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arax/4722445 to your computer and use it in GitHub Desktop.
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
# 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
@arax
Copy link
Author

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