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

feature #754: Fixing bugs. login and create users based on x509 works

This commit is contained in:
Ruben S. Montero 2011-08-26 00:45:46 +02:00
parent 304a888415
commit 2534cea8ae
4 changed files with 10 additions and 12 deletions

View File

@ -24,7 +24,7 @@ require 'fileutils'
# as auth method is defined. It also holds some helper methods to be used
# by oneauth command
class SshAuth
PROXY_PATH = ENV['HOME']+'/.one/one_ssh'
LOGIN_PATH = ENV['HOME']+'/.one/one_ssh'
attr_reader :public_key
@ -69,7 +69,7 @@ class SshAuth
expire ||= 3600
# Init proxy file path and creates ~/.one directory if needed
proxy_dir = File.dirname(PROXY_PATH)
proxy_dir = File.dirname(LOGIN_PATH)
begin
FileUtils.mkdir_p(proxy_dir)
@ -84,7 +84,7 @@ class SshAuth
proxy = "#{user}:ssh:#{secret_crypted}"
file = File.open(PROXY_PATH, "w")
file = File.open(LOGIN_PATH, "w")
file.write(proxy)
file.close

View File

@ -45,7 +45,7 @@ class X509Auth
end
if @options[:key_pem]
@key = OpenSSL::PKey::RSA.new(key_pem)
@key = OpenSSL::PKey::RSA.new(@options[:key_pem])
end
end
@ -71,7 +71,7 @@ class X509Auth
# - user_name:time_expires:cert_chain is base64 encoded
def login_token(user, expire)
if expire != 0
expires = Time.now.to_i+expire
expires = Time.now.to_i + expire.to_i
else
expires = @cert_chain[0].not_after.to_i
end

View File

@ -96,12 +96,10 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
options[:key] ||= ENV['X509_USER_KEY']
begin
certs = Array.new
certs[0] = File.read(options[:cert])
key = File.read(options[:key])
certs = [File.read(options[:cert])]
key = File.read(options[:key])
auth = X509Auth.new(:cert=>certs, :key=>key)
auth = X509Auth.new(:certs_pem=>certs, :key_pem=>key)
rescue Exception => e
return -1, e.message
end
@ -130,7 +128,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
auth.login(username, options[:time])
return 0, 'export ONE_AUTH=' << auth.class::PROXY_PATH
return 0, 'export ONE_AUTH=' << auth.class::LOGIN_PATH
end
private

View File

@ -171,7 +171,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
EOT
command :login, login_desc, :username, [:password, nil],
:options=>create_options do
:options=>login_options do
helper.login(args[0], options)
end