Class: Aspera::Cli::Plugins::BasicAuth
- Defined in:
- lib/aspera/cli/plugins/basic_auth.rb
Overview
base class for applications supporting basic authentication
Constant Summary
Constants inherited from Base
Aspera::Cli::Plugins::Base::FILTER_ARGS
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #basic_auth_api(subpath = nil) ⇒ Object
-
#basic_auth_params(subpath = nil) ⇒ Object
returns a Rest object with basic auth.
-
#initialize(context:, basic_options: true) ⇒ BasicAuth
constructor
A new instance of BasicAuth.
Methods inherited from Base
#action_for, #add_manual_header, application_name, #bulk_result, command, command_registry, commands_under, #config, crud_commands, declare_options, define_action_method, #dispatch_child, #dispatch_from_registry, #dispatch_leaf, #entity_create, #entity_delete, entity_display_name, #entity_list, #entity_modify, #entity_res_path, #entity_show, #execute_action, #execute_leaf, file_matcher, #formatter, #generate_help, #http_config, #invoke_action, option, #options, #persistency, #presets, #progress_bar, #query_read_delete, #resolve_argument, root_setup, #transfer, use_options, used_option_sources
Constructor Details
#initialize(context:, basic_options: true) ⇒ BasicAuth
Returns a new instance of BasicAuth.
15 16 17 18 19 20 21 |
# File 'lib/aspera/cli/plugins/basic_auth.rb', line 15 def initialize(context:, basic_options: true) super(context: context) # DSL options (url, username, password) are auto-declared by Base#initialize # via the ancestor chain. parse_options! is still needed here when basic_options # is true so callers that rely on parsing at construction time keep working. . if end |
Instance Method Details
#basic_auth_api(subpath = nil) ⇒ Object
37 38 39 |
# File 'lib/aspera/cli/plugins/basic_auth.rb', line 37 def basic_auth_api(subpath = nil) return Rest.new(**basic_auth_params(subpath)) end |
#basic_auth_params(subpath = nil) ⇒ Object
returns a Rest object with basic auth
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/aspera/cli/plugins/basic_auth.rb', line 24 def basic_auth_params(subpath = nil) api_url = .get_option(:url, mandatory: true) api_url = "#{api_url}/#{subpath}" unless subpath.nil? return { base_url: api_url, auth: { type: :basic, username: .get_option(:username, mandatory: true), password: .get_option(:password, mandatory: true) } } end |