Select the authentication protocols available

This commit is contained in:
Javi Fontan committed 2011-09-08 11:31:00 +02:00
1 parent a97f0c40fb
commit df90e53dce
1 file changed
+31 -3
+31 -3
View File
@@ -49,7 +49,9 @@ class AuthDriver < OpenNebulaDriver
#
# @param [String] the authorization method to be used, nil to use the
# built-in ACL engine
def initialize(authZ, nthreads)
# @param [Array] authentication modules enabled, nil will use any
# any method existing in remotes directory
def initialize(authZ, authN, nthreads)
super(
"auth",
:concurrency => nthreads,
@@ -66,6 +68,20 @@ class AuthDriver < OpenNebulaDriver
else
@authZ_cmd = nil
end
if authN == nil
# get the directories from remotes dir that have an authenticate
# script
@authN_protocols=Dir[@local_scripts_path+"/*/authenticate"].map do |d|
d.split('/')[-2]
end
else
if authN.class==String
@authN_protocols=[authN]
else
@authN_protocols=authN
end
end
end
# Authenticate a user based in a string of the form user:secret when using the
@@ -88,6 +104,14 @@ class AuthDriver < OpenNebulaDriver
secret_attr.shift
end
unless @authN_protocols.include?(protocol)
return send_message(
ACTION[:authN],
RESULT[:failure],
request_id,
"Authentication rotocol '#{protocol}' not available")
end
#build path for the auth action
#/var/lib/one/remotes/auth/<protocol>/authenticate
authN_path = File.join(@local_scripts_path, protocol)
@@ -133,11 +157,13 @@ end
# Auth Driver Main program
opts = GetoptLong.new(
[ '--threads', '-t', GetoptLong::REQUIRED_ARGUMENT ],
[ '--authz', '-z', GetoptLong::REQUIRED_ARGUMENT ]
[ '--authz', '-z', GetoptLong::REQUIRED_ARGUMENT ],
[ '--authn', '-n', GetoptLong::REQUIRED_ARGUMENT ]
)
threads = 15
authz = nil
authn = nil
begin
opts.each do |opt, arg|
@@ -146,12 +172,14 @@ begin
threads = arg.to_i
when '--authz'
authz = arg
when '--authn'
authn = arg.split(',').map {|a| a.strip }
end
end
rescue Exception => e
exit(-1)
end
auth_driver = AuthDriver.new(authz, threads)
auth_driver = AuthDriver.new(authz, authn, threads)
auth_driver.start_driver