Class: GrapeTokenAuth::Configuration
- Inherits:
-
Object
- Object
- GrapeTokenAuth::Configuration
- Defined in:
- lib/grape_token_auth/configuration.rb
Constant Summary collapse
- ACCESS_TOKEN_KEY =
'access-token'- EXPIRY_KEY =
'expiry'- UID_KEY =
'uid'- CLIENT_KEY =
'client'- EMAIL_VALIDATION =
/\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\z/- SERIALIZATION_BLACKLIST =
%i(encrypted_password reset_password_token reset_password_sent_at remember_created_at sign_in_count current_sign_in_at last_sign_in_at current_sign_in_ip last_sign_in_ip password_salt confirmation_token confirmed_at confirmation_sent_at remember_token unconfirmed_email failed_attempts unlock_token locked_at tokens)
Instance Attribute Summary collapse
-
#additional_serialization_blacklist ⇒ Object
Returns the value of attribute additional_serialization_blacklist.
-
#authentication_keys ⇒ Object
Returns the value of attribute authentication_keys.
-
#batch_request_buffer_throttle ⇒ Object
Returns the value of attribute batch_request_buffer_throttle.
-
#change_headers_on_each_request ⇒ Object
Returns the value of attribute change_headers_on_each_request.
-
#default_password_reset_url ⇒ Object
Returns the value of attribute default_password_reset_url.
-
#default_url_options ⇒ Object
Returns the value of attribute default_url_options.
-
#digest ⇒ Object
Returns the value of attribute digest.
-
#from_address ⇒ Object
Returns the value of attribute from_address.
-
#ignore_default_serialization_blacklist ⇒ Object
Returns the value of attribute ignore_default_serialization_blacklist.
-
#mailer ⇒ Object
Returns the value of attribute mailer.
-
#mappings ⇒ Object
Returns the value of attribute mappings.
-
#messages ⇒ Object
Returns the value of attribute messages.
-
#omniauth_prefix ⇒ Object
Returns the value of attribute omniauth_prefix.
-
#param_white_list ⇒ Object
Returns the value of attribute param_white_list.
-
#redirect_whitelist ⇒ Object
Returns the value of attribute redirect_whitelist.
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#smtp_configuration ⇒ Object
Returns the value of attribute smtp_configuration.
-
#token_lifespan ⇒ Object
Returns the value of attribute token_lifespan.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #key_generator ⇒ Object
- #scope_to_class(scope = nil) ⇒ Object
- #serialization_blacklist ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/grape_token_auth/configuration.rb', line 48 def initialize @token_lifespan = 60 * 60 * 24 * 7 * 2 # 2 weeks @batch_request_buffer_throttle = 5 # seconds @change_headers_on_each_request = true @mappings = {} @authentication_keys = [:email] @omniauth_prefix = '/omniauth' @additional_serialization_blacklist = [] @ignore_default_serialization_blacklist = false @default_password_reset_url = nil @smtp_configuration = {} @secret = nil @digest = 'SHA256' @messages = Mail::DEFAULT_MESSAGES @from_address = nil @default_url_options = {} @mailer = GrapeTokenAuth::Mail::SMTPMailer end |
Instance Attribute Details
#additional_serialization_blacklist ⇒ Object
Returns the value of attribute additional_serialization_blacklist.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def additional_serialization_blacklist @additional_serialization_blacklist end |
#authentication_keys ⇒ Object
Returns the value of attribute authentication_keys.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def authentication_keys @authentication_keys end |
#batch_request_buffer_throttle ⇒ Object
Returns the value of attribute batch_request_buffer_throttle.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def batch_request_buffer_throttle @batch_request_buffer_throttle end |
#change_headers_on_each_request ⇒ Object
Returns the value of attribute change_headers_on_each_request.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def change_headers_on_each_request @change_headers_on_each_request end |
#default_password_reset_url ⇒ Object
Returns the value of attribute default_password_reset_url.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def default_password_reset_url @default_password_reset_url end |
#default_url_options ⇒ Object
Returns the value of attribute default_url_options.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def @default_url_options end |
#digest ⇒ Object
Returns the value of attribute digest.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def digest @digest end |
#from_address ⇒ Object
Returns the value of attribute from_address.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def from_address @from_address end |
#ignore_default_serialization_blacklist ⇒ Object
Returns the value of attribute ignore_default_serialization_blacklist.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def ignore_default_serialization_blacklist @ignore_default_serialization_blacklist end |
#mailer ⇒ Object
Returns the value of attribute mailer.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def mailer @mailer end |
#mappings ⇒ Object
Returns the value of attribute mappings.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def mappings @mappings end |
#messages ⇒ Object
Returns the value of attribute messages.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def @messages end |
#omniauth_prefix ⇒ Object
Returns the value of attribute omniauth_prefix.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def omniauth_prefix @omniauth_prefix end |
#param_white_list ⇒ Object
Returns the value of attribute param_white_list.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def param_white_list @param_white_list end |
#redirect_whitelist ⇒ Object
Returns the value of attribute redirect_whitelist.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def redirect_whitelist @redirect_whitelist end |
#secret ⇒ Object
Returns the value of attribute secret.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def secret @secret end |
#smtp_configuration ⇒ Object
Returns the value of attribute smtp_configuration.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def smtp_configuration @smtp_configuration end |
#token_lifespan ⇒ Object
Returns the value of attribute token_lifespan.
29 30 31 |
# File 'lib/grape_token_auth/configuration.rb', line 29 def token_lifespan @token_lifespan end |
Instance Method Details
#key_generator ⇒ Object
67 68 69 70 |
# File 'lib/grape_token_auth/configuration.rb', line 67 def key_generator fail SecretNotSet unless secret @key_generator ||= CachingKeyGenerator.new(KeyGenerator.new(secret)) end |
#scope_to_class(scope = nil) ⇒ Object
77 78 79 80 |
# File 'lib/grape_token_auth/configuration.rb', line 77 def scope_to_class(scope = nil) fail MappingsUndefinedError if mappings.empty? mappings[scope] end |
#serialization_blacklist ⇒ Object
72 73 74 75 |
# File 'lib/grape_token_auth/configuration.rb', line 72 def serialization_blacklist additional_serialization_blacklist.map(&:to_sym).concat( ignore_default_serialization_blacklist ? [] : SERIALIZATION_BLACKLIST) end |