Class: HammerCLIForeman::Api::NegotiateAuth

Inherits:
ApipieBindings::Authenticators::Negotiate
  • Object
show all
Defined in:
lib/hammer_cli_foreman/api/negotiate_auth.rb

Instance Method Summary collapse

Constructor Details

#initialize(foreman_url, **options) ⇒ NegotiateAuth

Returns a new instance of NegotiateAuth.



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

def initialize(foreman_url, **options)
  super("#{foreman_url}/api/users/extlogin", HammerCLI::SSLOptions.new.get_options(foreman_url).merge(options))
end

Instance Method Details

#error(ex) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/hammer_cli_foreman/api/negotiate_auth.rb', line 24

def error(ex)
  super unless ex.is_a?(RestClient::Unauthorized)

  message = _('Invalid username or password.')
  begin
    message = JSON.parse(ex.response.body)['error']['message']
  rescue
  end
  UnauthorizedError.new(message)
end

#session_idObject



12
13
14
# File 'lib/hammer_cli_foreman/api/negotiate_auth.rb', line 12

def session_id
  auth_cookie&.delete_prefix('_session_id=')
end

#statusObject



16
17
18
19
20
21
22
# File 'lib/hammer_cli_foreman/api/negotiate_auth.rb', line 16

def status
  if system('klist')
    _('No session, but there is an active Kerberos session, that will be used for negotiate login.')
  else
    _('There is no active Kerberos session. Have you run %s?') % 'kinit'
  end
end

#userObject



8
9
10
# File 'lib/hammer_cli_foreman/api/negotiate_auth.rb', line 8

def user
  _('current Kerberos user')
end