class Backends::Opennebula::Authn::CloudAuth::ServerCipherAuth

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

Constants

CIPHER

Constants with paths to relevant files and defaults

Public Class Methods

new(srv_user, srv_passwd) click to toggle source
# File lib/backends/opennebula/authn/cloud_auth/server_cipher_auth.rb, line 33
def initialize(srv_user, srv_passwd)
  @srv_user   = srv_user
  @srv_passwd = srv_passwd

  if !srv_passwd.blank?
      @key = ::Digest::SHA1.hexdigest(@srv_passwd)
  else
      @key = ''
  end

  @cipher = ::OpenSSL::Cipher::Cipher.new(CIPHER)
end
new_client(srv_user, srv_passwd) click to toggle source

Creates a ServerCipher for client usage

# File lib/backends/opennebula/authn/cloud_auth/server_cipher_auth.rb, line 47
def self.new_client(srv_user, srv_passwd)
  new(srv_user, srv_passwd)
end

Public Instance Methods

login_token(expire, target_user = nil) click to toggle source

Generates a login token in the form:

- server_user:target_user:time_expires

The token is then encrypted with the contents of one_auth

# File lib/backends/opennebula/authn/cloud_auth/server_cipher_auth.rb, line 54
def login_token(expire, target_user = nil)
  target_user ||= @srv_user
  token_txt   =   "#{@srv_user}:#{target_user}:#{expire}"

  token   = encrypt(token_txt)
  token64 = ::Base64.encode64(token).strip.delete("\n")

  "#{@srv_user}:#{target_user}:#{token64}"
end
password() click to toggle source

Returns a valid password string to create a user using this auth driver

# File lib/backends/opennebula/authn/cloud_auth/server_cipher_auth.rb, line 65
def password
    @srv_passwd
end