class Clearance::Configuration
Attributes
Controls whether the password reset routes are enabled Defaults to ‘true`. Set to False to disable password reset routes The setting is ignored if routes are disabled. @param [Boolean] value @return [Boolean]
Controls whether the sign up route is enabled. Defaults to ‘true`. Set to `false` to disable user creation routes. The setting is ignored if routes are disabled. @param [Boolean] value @return [Boolean]
The array of allowed environments where ‘Clearance::BackDoor` is enabled. Defaults to [“test”, “ci”, “development”] @return [Array<String>]
Controls whether the HttpOnly flag should be set on the remember token cookie. Defaults to ‘true`, which prevents the cookie from being made available to JavaScript. For more see [RFC6265](tools.ietf.org/html/rfc6265#section-5.2.6). @return [Boolean]
Controls the address the password reset email is sent from. Defaults to reply@example.com. @return [String]
The controller class that all Clearance
controllers will inherit from. Defaults to ‘::ApplicationController`. @return [ActionController::Base]
The password strategy to use when authenticating and setting passwords. Defaults to {Clearance::PasswordStrategies::BCrypt}. @return [Module authenticated? password=]
The default path Clearance
will redirect signed in users to. Defaults to ‘“/”`. This can often be overridden for specific scenarios by overriding controller methods that rely on it. @return [String]
Set to ‘false` to disable Clearance’s built-in routes. Defaults to ‘true`. When set to false, your app is responsible for all routes. You can dump a copy of Clearance’s default routes with ‘rails generate clearance:routes`. @return [Boolean]
Same-site cookies (“First-Party-Only” or “First-Party”) allow servers to mitigate the risk of CSRF and information leakage attacks by asserting that a particular cookie should only be sent with requests initiated from the same registrable domain. Defaults to ‘nil`. For more, see [RFC6265](tools.ietf.org/html/draft-west-first-party-cookies-06#section-4.1.1). and github.com/rack/rack/blob/6eda04886e3a57918ca2d6a482fda02a678fef0a/lib/rack/utils.rb#L232-L244 @return [String]
The array of sign in guards to run when signing a user in. Defaults to an empty array. Sign in guards respond to ‘call` and are initialized with a session and the current stack. Each guard can decide to fail the sign in, yield to the next guard, or allow the sign in. @return [Array<#call>]
Controls wether users are automatically signed in after successfully resetting their password. Defaults to ‘true`. @return [Boolean]
The default path Clearance
will redirect non-users to when denied access. Defaults to ‘nil` so that the authorization module will use `sign_in_url` for backwards compatibility. This can be set here instead of overriding the method via an overridden authorization module. @return [String]
The default path Clearance
will redirect signed out users to. Defaults to ‘nil` so that the controller will use `sign_in_url` for backwards compatibility. This can be set here instead of overriding the method via an overridden session controller. @return [String]
The ActiveRecord class that represents users in your application. Defaults to ‘::User`. @return [ActiveRecord::Base]
The parameter for user routes. By default this is derived from the user model. @return [Symbol]
Public Class Methods
Source
# File lib/clearance/configuration.rb, line 153 def initialize @allow_sign_up = true @allow_password_reset = true @allowed_backdoor_environments = ["test", "ci", "development"] @cookie_domain = nil @cookie_expiration = ->(cookies) { 1.year.from_now.utc } @cookie_name = "remember_token" @cookie_path = '/' @httponly = true @same_site = nil @mailer_sender = 'reply@example.com' @redirect_url = '/' @url_after_destroy = nil @url_after_denied_access_when_signed_out = nil @rotate_csrf_on_sign_in = true @routes = true @secure_cookie = false @signed_cookie = false @sign_in_guards = [] @user_parameter = nil @sign_in_on_password_reset = true end
Public Instance Methods
Source
# File lib/clearance/configuration.rb, line 208 def allow_password_reset? @allow_password_reset end
Are the password reset routes enabled? @return [Boolean]
Source
# File lib/clearance/configuration.rb, line 202 def allow_sign_up? @allow_sign_up end
Is the user sign up route enabled? @return [Boolean]
Source
# File lib/clearance/configuration.rb, line 196 def parent_controller (@parent_controller || "ApplicationController").to_s.constantize end
The class representing the configured base controller. In the default configuration, this is the ‘ApplicationController` class. @return [Class]
Source
# File lib/clearance/configuration.rb, line 251 def reload_user_model if @user_model.present? @user_model = @user_model.to_s.constantize end end
Reloads the clearance user model class. This is called from the Clearance
engine to reload the configured user class during each request while in development mode, but only once in production.
@api private
Source
# File lib/clearance/configuration.rb, line 257 def rotate_csrf_on_sign_in? !!rotate_csrf_on_sign_in end
Source
# File lib/clearance/configuration.rb, line 241 def routes_enabled? @routes end
@return [Boolean] are Clearance’s built-in routes enabled?
Source
# File lib/clearance/configuration.rb, line 261 def sign_in_on_password_reset? @sign_in_on_password_reset end
Source
# File lib/clearance/configuration.rb, line 216 def user_actions if allow_sign_up? [:create] else [] end end
Specifies which controller actions are allowed for user resources. This will be ‘[:create]` is `allow_sign_up` is true (the default), and empty otherwise. @return [Array<Symbol>]
Source
# File lib/clearance/configuration.rb, line 236 def user_id_parameter "#{user_parameter}_id".to_sym end
The name of foreign key parameter for the configured user model. This is derived from the ‘model_name` of the `user_model` setting. In the default configuration, this is `user_id`. @return [Symbol]
Source
# File lib/clearance/configuration.rb, line 189 def user_model (@user_model || "User").to_s.constantize end
The class representing the configured user model. In the default configuration, this is the ‘User` class. @return [Class]
Source
# File lib/clearance/configuration.rb, line 228 def user_parameter @user_parameter ||= user_model.model_name.singular.to_sym end
The name of user parameter for the configured user model. This is derived from the ‘model_name` of the `user_model` setting. In the default configuration, this is `user`. @return [Symbol]