class Negroni::Configuration

`Configuration` encapsulates all of the configuration for Negroni, keeping it out of the main module.

Constants

DEFAULT_EMAIL_VALIDATION_REGEX

The default email validation regex.

Attributes

authentication_keys[RW]

Keys used when authenticating @return [Array<Symbol>]

case_insensitive_keys[RW]

Keys that should be treated as case-insensitive @return [Array<Symbol>]

email_regexp[RW]

Regular expression to validate emails @return [RegExp]

lock_strategy[RW]

Defines which strategy will be used to lock an account.

* `:failed_attempts` = Locks an account after a number of failed
        attempts.
* `:none`            = No lock strategy. You should handle locking by
        yourself.

@return [Symbol] the name of the lock strategy.

mailer_sender[RW]

The sender for all mailers @return [String] the email address for the sender

maximum_attempts[RW]

Number of authentication tries before locking an account @return [Integer]

not_found_exception[RW]

The name of the exception class that will be raised upon receiving an invalid auth token.

Default: {Negroni::TokenNotFound}

@return [Class, String]

parent_controller[RW]

The class `Negroni::BaseController` should inherit from.

Default: ActionController::API

@return [String, Class]

parent_mailer[RW]

The class `Mailer` should inherit from (`'ActionMailer::Base'` by default) @return [String]

password_length[RW]

Range validation for password @return [Range]

pepper[RW]

Used to hash the password. Generate one with `rake secret`. @return [String] the pepper used to hash the password

reset_password_keys[RW]

Defines which key will be used when recovering the password for an account @return [Array<Symbol>]

reset_password_within[RW]

Time interval you can reset your password with a reset password key @return [ActiveSupport::Duration]

send_password_change_notification[RW]

When true, send an email to notify password changes @return [Boolean]

stretches[RW]

The number of times to hash the password @return [Integer]

strip_whitespace_keys[RW]

Keys that should have whitespace skipped @return [Array<Symbol>]

token_algorithm[RW]

The algorithm used to encode the token. Default: 'HS256'

@return [String]

token_audience[RW]

The audience claim to identify the recipients that the token is intended for.

@return [Object]

token_lifetime[RW]

How long before a token is expired. If nil is provided, token will last forever.

@return [ActiveSupport::Duration]

token_public_key[RW]

An optional public key used to decode tokens.

@return [String]

token_secret[RW]

The secret key that will be used for the token. Default: {Negroni::secret_key}.

@return [String]

unlock_in[RW]

Time interval to unlock the account if `:time` is defined as `unlock_strategy`.

@return [ActiveSupport::Duration]

unlock_keys[RW]

Defines which key will be used when locking and unlocking an account @return [Array<Symbol>]

unlock_strategy[RW]

Defines which strategy can be used to unlock an account. Valid values: `:email,` `:time,` `:both` @return [Symbol]

Public Class Methods

new() click to toggle source

Create a new instance of `Configuration`, using default values for all attributes.

# File lib/negroni/configuration.rb, line 147
def initialize # rubocop:disable Metrics/AbcSize,MethodLength
  @authentication_keys = [:email]
  @case_insensitive_keys = [:email]
  @strip_whitespace_keys = [:email]
  @send_password_change_notification = false
  @token_lifetime = 1.day
  @token_algorithm = 'HS256'
  @not_found_exception = 'Negroni::TokenNotFound'
  @email_regexp = DEFAULT_EMAIL_VALIDATION_REGEX
  @password_length = 8..72
  @stretches = 11
  @pepper = nil
  @lock_strategy = :failed_attempts
  @unlock_keys = [:email]
  @unlock_strategy = :both
  @maximum_attempts = 20
  @unlock_in = 1.hour
  @reset_password_keys = [:email]
  @reset_password_within = 6.hours
  @mailer_sender = nil
  @parent_mailer = 'ActionMailer::Base'
  @parent_controller = 'ActionController::API'
end