Class: TrainPlugins::Rest::AuthHandler
- Inherits:
-
Object
- Object
- TrainPlugins::Rest::AuthHandler
- Defined in:
- lib/train-rest/auth_handler.rb
Overview
Class to derive authentication handlers from.
Direct Known Subclasses
AWSV4, Anonymous, AuthtypeApikey, Basic, Bearer, Header, HmacSignature, Redfish
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
-
.descendants ⇒ Array
List authentication handlers.
-
.name ⇒ String
Return name of handler.
Instance Method Summary collapse
-
#auth_headers ⇒ Hash
Headers added to the rest-client call.
-
#auth_parameters ⇒ Hash
These will get added to the rest-client call.
-
#check_options ⇒ Object
Verify transport options.
-
#initialize(connection = nil) ⇒ AuthHandler
constructor
A new instance of AuthHandler.
-
#login ⇒ Object
Handle login.
-
#logout ⇒ Object
Handle logout.
-
#process(payload: "", headers: {}, url: "", method: nil) ⇒ Object
Return headers based on payload signing.
-
#process_error(_error) ⇒ Object
Allow processing errors related to authentication.
-
#renew_session ⇒ Object
Handle session renewal.
-
#renewal_needed? ⇒ Boolean
Return if session renewal needs to happen soon.
-
#signature_based? ⇒ Boolean
This Auth Handler will need payload, URI and headers, e.g.
Constructor Details
#initialize(connection = nil) ⇒ AuthHandler
Returns a new instance of AuthHandler.
8 9 10 |
# File 'lib/train-rest/auth_handler.rb', line 8 def initialize(connection = nil) @connection = connection end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
5 6 7 |
# File 'lib/train-rest/auth_handler.rb', line 5 def connection @connection end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/train-rest/auth_handler.rb', line 6 def @options end |
Class Method Details
.descendants ⇒ Array
List authentication handlers
24 25 26 |
# File 'lib/train-rest/auth_handler.rb', line 24 def self.descendants ObjectSpace.each_object(Class).select { |klass| klass < self } end |
.name ⇒ String
Return name of handler
15 16 17 18 19 |
# File 'lib/train-rest/auth_handler.rb', line 15 def self.name class_name = self.to_s.split("::").last convert_to_snake_case(class_name) end |
Instance Method Details
#auth_headers ⇒ Hash
Headers added to the rest-client call
58 59 60 |
# File 'lib/train-rest/auth_handler.rb', line 58 def auth_headers {} end |
#auth_parameters ⇒ Hash
These will get added to the rest-client call.
66 67 68 |
# File 'lib/train-rest/auth_handler.rb', line 66 def auth_parameters { headers: auth_headers } end |
#check_options ⇒ Object
Verify transport options
39 |
# File 'lib/train-rest/auth_handler.rb', line 39 def ; end |
#login ⇒ Object
Handle login
42 |
# File 'lib/train-rest/auth_handler.rb', line 42 def login; end |
#logout ⇒ Object
Handle logout
53 |
# File 'lib/train-rest/auth_handler.rb', line 53 def logout; end |
#process(payload: "", headers: {}, url: "", method: nil) ⇒ Object
Return headers based on payload signing.
85 86 87 |
# File 'lib/train-rest/auth_handler.rb', line 85 def process(payload: "", headers: {}, url: "", method: nil) {} end |
#process_error(_error) ⇒ Object
Allow processing errors related to authentication.
92 |
# File 'lib/train-rest/auth_handler.rb', line 92 def process_error(_error); end |
#renew_session ⇒ Object
Handle session renewal
45 |
# File 'lib/train-rest/auth_handler.rb', line 45 def renew_session; end |
#renewal_needed? ⇒ Boolean
Return if session renewal needs to happen soon
50 |
# File 'lib/train-rest/auth_handler.rb', line 50 def renewal_needed?; end |
#signature_based? ⇒ Boolean
This Auth Handler will need payload, URI and headers, e.g. for signatures.
73 74 75 |
# File 'lib/train-rest/auth_handler.rb', line 73 def signature_based? false end |