Class: Aspera::Cli::Plugins::Oauth
- Defined in:
- lib/aspera/cli/plugins/oauth.rb
Overview
base class for applications supporting OAuth 2.0 authentication
Constant Summary collapse
- AUTH_TYPES =
OAuth methods supported (web, jwt)
%i[web jwt boot].freeze
- AUTH_OPTIONS =
Options used for authentication (url, auth, client_id, etc…)
%i[url auth client_id client_secret redirect_uri private_key passphrase username password].freeze
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.kwargs_from_options(options) ⇒ Hash{Symbol => Object}
Get command line ‘options` specified by `AUTH_OPTIONS`.
Instance Method Summary collapse
-
#initialize(**_) ⇒ Oauth
constructor
A new instance of Oauth.
Methods inherited from BasicAuth
#basic_auth_api, #basic_auth_params, declare_options
Methods inherited from Base
#add_manual_header, #config, declare_options, #do_bulk_operation, #entity_execute, #formatter, #options, #persistency, #query_read_delete, #transfer, #value_create_modify
Constructor Details
#initialize(**_) ⇒ Oauth
Returns a new instance of Oauth.
31 32 33 34 35 36 37 38 39 |
# File 'lib/aspera/cli/plugins/oauth.rb', line 31 def initialize(**_) super .declare(:auth, 'OAuth type of authentication', allowed: AUTH_TYPES, default: :jwt) .declare(:client_id, 'OAuth client identifier') .declare(:client_secret, 'OAuth client secret') .declare(:redirect_uri, 'OAuth (Web) redirect URI for web authentication') .declare(:private_key, 'OAuth (JWT) RSA private key PEM value (prefix file path with @file:)') .declare(:passphrase, 'OAuth (JWT) RSA private key passphrase') end |
Class Method Details
.kwargs_from_options(options) ⇒ Hash{Symbol => Object}
Get command line ‘options` specified by `AUTH_OPTIONS`
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/aspera/cli/plugins/oauth.rb', line 15 def () AUTH_OPTIONS.each_with_object({}) do |i, m| v = .get_option(i) m[i] = v unless v.nil? end rescue ::ArgumentError => e if (m = e..match(/missing keyword: :(.*)$/)) raise Cli::Error, "Missing option: #{m[1]}" end raise end |