Sha256: 056c92dcf787aaefe1526b7263f1f47467e2d5ef293499584b15f2c78f879a86
Contents?: true
Size: 1.34 KB
Versions: 3
Compression:
Stored size: 1.34 KB
Contents
require 'lp_token_auth/error' module LpTokenAuth # `LpTokenAuth::Config` manages the configuration options for the token. # These can be set with the initializer provided with the generator. class Config # Creates virtual attributes for configuration options: # * `algorithm` is a string corresponding to token encryption algorithm to use # * `expires` is an integer corresponding to the number of hours that the token is active # * `secret` is a string corresponding to the secret key used when encrypting the token # * `token_transport` is a string indicating where to include the token in the HTTP response attr_accessor :algorithm, :expires, :secret, :token_transport # Provides default values to token options DEFAULT_VALUES = { algorithm: 'HS512', expires: (7 * 24), token_transport: [:cookie], } # Retrieves value for token option, either as set by the application, or the default # @param [Symbol] key the token option name # @raise [LpTokenAuth::Error] if the option has not been set by the application and a default value does not exist # @return [String,Integer] the value of the token option def get_option(key) option = send(key) || DEFAULT_VALUES[key] raise LpTokenAuth::Error "Missing config option value: #{ key }" unless option option end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lp_token_auth-2.0.0 | lib/lp_token_auth/config.rb |
lp_token_auth-1.0.0 | lib/lp_token_auth/config.rb |
lp_token_auth-0.3.0 | lib/lp_token_auth/config.rb |