Class: HammerCLIForeman::Api::Authenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/hammer_cli_foreman/api/authenticator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auth_type, uri, settings) ⇒ Authenticator

Returns a new instance of Authenticator.



5
6
7
8
9
# File 'lib/hammer_cli_foreman/api/authenticator.rb', line 5

def initialize(auth_type, uri, settings)
  @auth_type = auth_type
  @uri = uri
  @settings = settings
end

Instance Attribute Details

#auth_typeObject

Returns the value of attribute auth_type.



4
5
6
# File 'lib/hammer_cli_foreman/api/authenticator.rb', line 4

def auth_type
  @auth_type
end

#settingsObject

Returns the value of attribute settings.



4
5
6
# File 'lib/hammer_cli_foreman/api/authenticator.rb', line 4

def settings
  @settings
end

#uriObject

Returns the value of attribute uri.



4
5
6
# File 'lib/hammer_cli_foreman/api/authenticator.rb', line 4

def uri
  @uri
end

Instance Method Details

#fetchObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hammer_cli_foreman/api/authenticator.rb', line 11

def fetch
  if ssl_cert_authentication? && !use_basic_auth?
    void_auth
  elsif auth_type == AUTH_TYPES[:basic_auth]
    basic_auth
  elsif auth_type == AUTH_TYPES[:basic_auth_external]
    basic_auth_external
  elsif auth_type == AUTH_TYPES[:negotiate]
    negotiate_auth
  elsif auth_type == AUTH_TYPES[:oauth_password_grant]
    oauth_password_grant
  elsif auth_type == AUTH_TYPES[:oauth_authentication_code_grant]
    oauth_authentication_code_grant
  end
end