Module: Aspera::Cli::Plugins::BasicAuth
- Extended by:
- Option::Declarator
- Included in:
- Oauth, Plugins::Alee::Commands, Plugins::Console::Commands, Plugins::Faspio::Commands, Plugins::Node::Commands, Plugins::Orchestrator::Commands, Plugins::Preview::Commands, Plugins::Server::Commands, Plugins::Shares::Commands
- Defined in:
- lib/aspera/cli/plugins/basic_auth.rb
Overview
Module for plugins of applications supporting basic authentication: include Cli::Plugins::BasicAuth in a plugin class.
Its included hook gives the options of the module to the plugin class (use_options); Oauth includes this module and adds the options itself.
Class Method Summary collapse
Instance Method Summary collapse
- #basic_auth_api(subpath = nil) ⇒ Object
-
#basic_auth_params(subpath = nil) ⇒ Object
returns a Rest::Client object with basic auth.
Methods included from Option::Declarator
declare_options, option, option_specs, register_option_spec
Class Method Details
.included(base) ⇒ Object
19 20 21 22 |
# File 'lib/aspera/cli/plugins/basic_auth.rb', line 19 def included(base) super base.(self) if base.is_a?(Class) end |
Instance Method Details
#basic_auth_api(subpath = nil) ⇒ Object
43 44 45 |
# File 'lib/aspera/cli/plugins/basic_auth.rb', line 43 def basic_auth_api(subpath = nil) return Rest::Client.new(**basic_auth_params(subpath)) end |
#basic_auth_params(subpath = nil) ⇒ Object
returns a Rest::Client object with basic auth
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aspera/cli/plugins/basic_auth.rb', line 30 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 |