Class: Gruf::Authentication::Base
- Inherits:
-
Object
- Object
- Gruf::Authentication::Base
- Includes:
- Loggable
- Defined in:
- lib/gruf/authentication/base.rb
Overview
Base interface for Authentication strategies. All derived strategies must define the ‘valid?` method.
Instance Attribute Summary collapse
-
#credentials ⇒ String
readonly
The credentials sent in the request.
-
#options ⇒ Hash
readonly
A hash of authentication options.
Class Method Summary collapse
-
.verify(call, credentials = '', options = {}) ⇒ Object
Verify the credentials.
Instance Method Summary collapse
-
#initialize(credentials, options = {}) ⇒ Base
constructor
Initialize the authentication middleware.
-
#valid?(_call) ⇒ Boolean
Abstract method that is required to be implemented in every derivative class.
Methods included from Loggable
Constructor Details
Instance Attribute Details
#credentials ⇒ String (readonly)
Returns The credentials sent in the request.
26 27 28 |
# File 'lib/gruf/authentication/base.rb', line 26 def credentials @credentials end |
#options ⇒ Hash (readonly)
Returns A hash of authentication options.
28 29 30 |
# File 'lib/gruf/authentication/base.rb', line 28 def @options end |
Class Method Details
.verify(call, credentials = '', options = {}) ⇒ Object
Verify the credentials. Helper class method.
49 50 51 |
# File 'lib/gruf/authentication/base.rb', line 49 def self.verify(call, credentials = '', = {}) new(credentials, ).valid?(call) end |
Instance Method Details
#valid?(_call) ⇒ Boolean
Abstract method that is required to be implemented in every derivative class. Return true if the call is authenticated, false if a permission denied error is to be sent.
60 61 62 |
# File 'lib/gruf/authentication/base.rb', line 60 def valid?(_call) raise NotImplementedError end |