Class: HammerCLIForeman::Api::InteractiveBasicAuth
- Inherits:
-
ApipieBindings::Authenticators::BasicAuth
- Object
- ApipieBindings::Authenticators::BasicAuth
- HammerCLIForeman::Api::InteractiveBasicAuth
- Defined in:
- lib/hammer_cli_foreman/api/interactive_basic_auth.rb
Instance Method Summary collapse
- #authenticate(request, args) ⇒ Object
- #clear ⇒ Object
- #error(ex) ⇒ Object
- #password(ask = nil) ⇒ Object
- #set_credentials(user, password) ⇒ Object
- #status ⇒ Object
- #user(ask = nil) ⇒ Object
Instance Method Details
#authenticate(request, args) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/hammer_cli_foreman/api/interactive_basic_auth.rb', line 4 def authenticate(request, args) if HammerCLI.interactive? get_user get_password end super end |
#clear ⇒ Object
45 46 47 |
# File 'lib/hammer_cli_foreman/api/interactive_basic_auth.rb', line 45 def clear set_credentials(nil, nil) end |
#error(ex) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/hammer_cli_foreman/api/interactive_basic_auth.rb', line 12 def error(ex) if ex.is_a?(RestClient::Unauthorized) self.clear = _('Invalid username or password.') begin = JSON.parse(ex.response.body)['error']['message'] rescue end UnauthorizedError.new() end end |
#password(ask = nil) ⇒ Object
36 37 38 |
# File 'lib/hammer_cli_foreman/api/interactive_basic_auth.rb', line 36 def password(ask=nil) @password ||= ask && get_password end |
#set_credentials(user, password) ⇒ Object
40 41 42 43 |
# File 'lib/hammer_cli_foreman/api/interactive_basic_auth.rb', line 40 def set_credentials(user, password) @user = user @password = password end |
#status ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/hammer_cli_foreman/api/interactive_basic_auth.rb', line 24 def status unless @user.nil? || @password.nil? _("Using configured credentials for user '%s'.") % @user else _("Credentials are not configured.") end end |
#user(ask = nil) ⇒ Object
32 33 34 |
# File 'lib/hammer_cli_foreman/api/interactive_basic_auth.rb', line 32 def user(ask=nil) @user ||= ask && get_user end |