1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

bug #847: New password method for Auth drivers. oneuser command update to make use of it

This commit is contained in:
Ruben S. Montero 2011-10-24 18:14:49 +02:00
parent 0bd23e33d9
commit 37b180df84
4 changed files with 25 additions and 16 deletions

View File

@ -48,8 +48,8 @@ class ServerCipherAuth
auth.rstrip!
@server_user, passwd = auth.split(':')
@key = Digest::SHA1.hexdigest(passwd)
@server_user, @passwd = auth.split(':')
@key = Digest::SHA1.hexdigest(@passwd)
@cipher = OpenSSL::Cipher::Cipher.new(CIPHER)
rescue
@ -70,6 +70,10 @@ class ServerCipherAuth
return "#{@server_user}:#{token64}"
end
# Returns a valid password string to create a user using this auth driver
def password
return @passwd
end
###########################################################################
# Server side
###########################################################################

View File

@ -91,6 +91,12 @@ class SshAuth
secret_crypted
end
# Returns a valid password string to create a user using this auth driver.
# In this case the dn of the user certificate.
def password
@public_key
end
# Checks the proxy created with the login method
def authenticate(user, token)
begin

View File

@ -79,8 +79,9 @@ class X509Auth
write_login(login_token(user,expire))
end
# Returns the dn of the user certificate
def dn
# Returns a valid password string to create a user using this auth driver.
# In this case the dn of the user certificate.
def password
@cert_chain[0].subject.to_s.delete("\s")
end

View File

@ -37,11 +37,11 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
return -1, "Can not read file: #{arg}"
end
else
if options[:x509]
password = arg.delete("\s")
else
password = arg
end
password = arg
end
if options[:x509]
password.delete!("\s")
end
return 0, password
@ -56,12 +56,10 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
require 'ssh_auth'
begin
sshauth = SshAuth.new(:private_key=>options[:key])
auth = SshAuth.new(:private_key=>options[:key])
rescue Exception => e
return -1, e.message
end
return 0, sshauth.public_key
elsif options[:x509]
options[:cert] ||= ENV['X509_USER_CERT']
@ -72,16 +70,16 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
require 'x509_auth'
begin
cert = [File.read(options[:cert])]
x509auth = X509Auth.new(:certs_pem=>cert)
cert = [File.read(options[:cert])]
auth = X509Auth.new(:certs_pem=>cert)
rescue Exception => e
return -1, e.message
end
return 0, x509auth.dn
else
return -1, "You have to specify an Auth method or define a password"
end
return 0, auth.password
end
def self.login(username, options)