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
- #set_credentials(user, password) ⇒ Object
- #status ⇒ Object
- #user(ask = nil) ⇒ Object
Instance Method Details
#authenticate(request, args) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/hammer_cli_foreman/api/interactive_basic_auth.rb', line 6 def authenticate(request, args) if HammerCLI.interactive? get_user get_password end super end |
#clear ⇒ Object
38 39 40 |
# File 'lib/hammer_cli_foreman/api/interactive_basic_auth.rb', line 38 def clear set_credentials(nil, nil) end |
#error(ex) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/hammer_cli_foreman/api/interactive_basic_auth.rb', line 14 def error(ex) if ex.is_a?(RestClient::Unauthorized) self.clear return UnauthorizedError.new(_("Invalid username or password.")) end end |
#set_credentials(user, password) ⇒ Object
33 34 35 36 |
# File 'lib/hammer_cli_foreman/api/interactive_basic_auth.rb', line 33 def set_credentials(user, password) @user = user @password = password end |
#status ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/hammer_cli_foreman/api/interactive_basic_auth.rb', line 21 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
29 30 31 |
# File 'lib/hammer_cli_foreman/api/interactive_basic_auth.rb', line 29 def user(ask=nil) @user ||= ask && get_user end |