1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-28 17:57:22 +03:00

feature #1700: move auth libraries to OpenNebula module

This commit is contained in:
Javi Fontan 2012-12-20 04:47:39 -06:00
parent eb1917fb4a
commit 28773a229e
11 changed files with 39 additions and 22 deletions

View File

@ -406,6 +406,7 @@ INSTALL_FILES=(
INCLUDE_FILES:$INCLUDE_LOCATION
LIB_FILES:$LIB_LOCATION
RUBY_LIB_FILES:$LIB_LOCATION/ruby
RUBY_AUTH_LIB_FILES:$LIB_LOCATION/ruby/opennebula
RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/opennebula
MAD_RUBY_LIB_FILES:$LIB_LOCATION/ruby
MAD_RUBY_LIB_FILES:$VAR_LOCATION/remotes
@ -673,8 +674,13 @@ RUBY_LIB_FILES="src/mad/ruby/ActionManager.rb \
src/mad/ruby/ssh_stream.rb \
src/vnm_mad/one_vnm.rb \
src/mad/ruby/Ganglia.rb \
src/oca/ruby/opennebula.rb \
src/authm_mad/remotes/ssh/ssh_auth.rb \
src/oca/ruby/opennebula.rb"
#-------------------------------------------------------------------------------
# Ruby auth library files, to be installed under $LIB_LOCATION/ruby/opennebula
#-------------------------------------------------------------------------------
RUBY_AUTH_LIB_FILES="src/authm_mad/remotes/ssh/ssh_auth.rb \
src/authm_mad/remotes/server_x509/server_x509_auth.rb \
src/authm_mad/remotes/server_cipher/server_cipher_auth.rb \
src/authm_mad/remotes/ldap/ldap_auth.rb \

View File

@ -29,7 +29,7 @@ end
$: << RUBY_LIB_LOCATION
require 'yaml'
require 'ldap_auth'
require 'opennebula/ldap_auth'
require 'uri'
if defined?(URI::Parser)
@ -66,7 +66,7 @@ order.each do |server_name|
end
begin
ldap=LdapAuth.new(server_conf)
ldap=OpenNebula::LdapAuth.new(server_conf)
user_name=ldap.find_user(user)

View File

@ -17,7 +17,9 @@
require 'rubygems'
require 'net/ldap'
class LdapAuth
module OpenNebula; end
class OpenNebula::LdapAuth
def initialize(options)
@options={
:host => 'localhost',

View File

@ -28,7 +28,7 @@ end
$: << RUBY_LIB_LOCATION
require 'server_cipher_auth'
require 'opennebula/server_cipher_auth'
require 'scripts_common'
user = ARGV[0] # username as registered in OpenNebula
@ -38,7 +38,7 @@ secret = ARGV[2] # Base64 encoded secret as obtained from login_token
#OpenNebula.log_debug("Authenticating #{user}, with password #{pass} (#{secret})")
begin
server_auth = ServerCipherAuth.new_driver
server_auth = OpenNebula::ServerCipherAuth.new_driver
rc = server_auth.authenticate(user, pass, secret)
rescue => e
OpenNebula.error_message e.message
@ -50,4 +50,4 @@ if rc == true
else
OpenNebula.error_message rc
exit -1
end
end

View File

@ -20,10 +20,12 @@ require 'digest/sha1'
require 'base64'
require 'fileutils'
module OpenNebula; end
# Server authentication class. This method can be used by OpenNebula services
# to let access authenticated users by other means. It is based on OpenSSL
# symmetric ciphers
class ServerCipherAuth
class OpenNebula::ServerCipherAuth
###########################################################################
#Constants with paths to relevant files and defaults
###########################################################################
@ -142,4 +144,5 @@ class ServerCipherAuth
return rc
end
end
end

View File

@ -28,7 +28,7 @@ end
$: << RUBY_LIB_LOCATION
require 'server_x509_auth'
require 'opennebula/server_x509_auth'
require 'scripts_common'
user = ARGV[0] # username as registered in OpenNebula
@ -38,7 +38,7 @@ secret = ARGV[2] # Base64 encoded secret as obtained from login_token
#OpenNebula.log_debug("Authenticating #{user}, with password #{pass} (#{secret})")
begin
server_auth = ServerX509Auth.new
server_auth = OpenNebula::ServerX509Auth.new
dsecret = Base64::decode64(secret)
rc = server_auth.authenticate(user, pass, dsecret)

View File

@ -18,12 +18,14 @@ require 'openssl'
require 'base64'
require 'fileutils'
require 'x509_auth'
require 'opennebula/x509_auth'
module OpenNebula; end
# Server authentication class. This authmethod can be used by opennebula services
# to let access authenticated users by other means. It is based on x509 server
# certificates
class ServerX509Auth < X509Auth
class OpenNebula::ServerX509Auth < OpenNebula::X509Auth
###########################################################################
#Constants with paths to relevant files and defaults
###########################################################################
@ -61,7 +63,7 @@ class ServerX509Auth < X509Auth
###########################################################################
# Creates a ServerCipher for client and driver sage
class << ServerX509Auth
class << OpenNebula::ServerX509Auth
alias :new_client :new
alias :new_driver :new
end
@ -99,4 +101,4 @@ class ServerX509Auth < X509Auth
return e.message
end
end
end
end

View File

@ -28,7 +28,7 @@ end
$: << RUBY_LIB_LOCATION
require 'ssh_auth'
require 'opennebula/ssh_auth'
require 'scripts_common'
user = ARGV[0]
@ -37,7 +37,7 @@ secret = ARGV[2]
#OpenNebula.log_debug("Authenticating #{user}, with password #{pass} (#{secret})")
begin
ssh_auth = SshAuth.new(:public_key=>pass)
ssh_auth = OpenNebula::SshAuth.new(:public_key=>pass)
rescue Exception => e
OpenNebula.error_message e.message
exit -1

View File

@ -20,10 +20,12 @@ require 'openssl'
require 'base64'
require 'fileutils'
module OpenNebula; end
# SSH key authentication class. It can be used as a driver for auth_mad
# as auth method is defined. It also holds some helper methods to be used
# by oneauth command
class SshAuth
class OpenNebula::SshAuth
LOGIN_PATH = ENV['HOME']+'/.one/one_ssh'
# Initialize SshAuth object

View File

@ -28,7 +28,7 @@ end
$: << RUBY_LIB_LOCATION
require 'x509_auth'
require 'opennebula/x509_auth'
require 'scripts_common'
user = ARGV[0] # username as registered in OpenNebula
@ -44,7 +44,7 @@ begin
token = asecret[0]
certs = asecret[1..-1]
x509_auth = X509Auth.new(:certs_pem=>certs)
x509_auth = OpenNebula::X509Auth.new(:certs_pem=>certs)
rc = x509_auth.authenticate(user, pass, token)
rescue => e

View File

@ -19,10 +19,12 @@ require 'base64'
require 'fileutils'
require 'yaml'
module OpenNebula; end
# X509 authentication class. It can be used as a driver for auth_mad
# as auth method is defined. It also holds some helper methods to be used
# by oneauth command
class X509Auth
class OpenNebula::X509Auth
###########################################################################
#Constants with paths to relevant files and defaults
###########################################################################