Class: LpTokenAuth::Config
- Inherits:
-
Object
- Object
- LpTokenAuth::Config
- Defined in:
- lib/lp_token_auth/config.rb
Overview
LpTokenAuth::Config manages the configuration options for the token.
These can be set with the initializer provided with the generator.
Constant Summary collapse
- DEFAULT_VALUES =
Provides default values to token options
{ algorithm: 'HS512', expires: (7 * 24), token_transport: [:cookie], }
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
Creates virtual attributes for configuration options: *
algorithmis a string corresponding to token encryption algorithm to use *expiresis an integer corresponding to the number of hours that the token is active *secretis a string corresponding to the secret key used when encrypting the token *token_transportis a string indicating where to include the token in the HTTP response. -
#expires ⇒ Object
Creates virtual attributes for configuration options: *
algorithmis a string corresponding to token encryption algorithm to use *expiresis an integer corresponding to the number of hours that the token is active *secretis a string corresponding to the secret key used when encrypting the token *token_transportis a string indicating where to include the token in the HTTP response. -
#secret ⇒ Object
Creates virtual attributes for configuration options: *
algorithmis a string corresponding to token encryption algorithm to use *expiresis an integer corresponding to the number of hours that the token is active *secretis a string corresponding to the secret key used when encrypting the token *token_transportis a string indicating where to include the token in the HTTP response. -
#token_transport ⇒ Object
Creates virtual attributes for configuration options: *
algorithmis a string corresponding to token encryption algorithm to use *expiresis an integer corresponding to the number of hours that the token is active *secretis a string corresponding to the secret key used when encrypting the token *token_transportis a string indicating where to include the token in the HTTP response.
Instance Method Summary collapse
-
#get_option(key) ⇒ String, Integer
Retrieves value for token option, either as set by the application, or the default.
Instance Attribute Details
#algorithm ⇒ Object
Creates virtual attributes for configuration options:
algorithmis a string corresponding to token encryption algorithm to useexpiresis an integer corresponding to the number of hours that the token is activesecretis a string corresponding to the secret key used when encrypting the tokentoken_transportis a string indicating where to include the token in the HTTP response
12 13 14 |
# File 'lib/lp_token_auth/config.rb', line 12 def algorithm @algorithm end |
#expires ⇒ Object
Creates virtual attributes for configuration options:
algorithmis a string corresponding to token encryption algorithm to useexpiresis an integer corresponding to the number of hours that the token is activesecretis a string corresponding to the secret key used when encrypting the tokentoken_transportis a string indicating where to include the token in the HTTP response
12 13 14 |
# File 'lib/lp_token_auth/config.rb', line 12 def expires @expires end |
#secret ⇒ Object
Creates virtual attributes for configuration options:
algorithmis a string corresponding to token encryption algorithm to useexpiresis an integer corresponding to the number of hours that the token is activesecretis a string corresponding to the secret key used when encrypting the tokentoken_transportis a string indicating where to include the token in the HTTP response
12 13 14 |
# File 'lib/lp_token_auth/config.rb', line 12 def secret @secret end |
#token_transport ⇒ Object
Creates virtual attributes for configuration options:
algorithmis a string corresponding to token encryption algorithm to useexpiresis an integer corresponding to the number of hours that the token is activesecretis a string corresponding to the secret key used when encrypting the tokentoken_transportis a string indicating where to include the token in the HTTP response
12 13 14 |
# File 'lib/lp_token_auth/config.rb', line 12 def token_transport @token_transport end |
Instance Method Details
#get_option(key) ⇒ String, Integer
Retrieves value for token option, either as set by the application, or the default
25 26 27 28 29 |
# File 'lib/lp_token_auth/config.rb', line 25 def get_option(key) option = send(key) || DEFAULT_VALUES[key] raise LpTokenAuth::Error "Missing config option value: #{ key }" unless option option end |