devise.rb 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. # Use this hook to configure devise mailer, warden hooks and so forth.
  2. # Many of these configuration options can be set straight in your model.
  3. Devise.setup do |config|
  4. # ==> Mailer Configuration
  5. # Configure the e-mail address which will be shown in Devise::Mailer,
  6. # note that it will be overwritten if you use your own mailer class
  7. # with default "from" parameter.
  8. config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
  9. # Configure the class responsible to send e-mails.
  10. # config.mailer = "Devise::Mailer"
  11. # ==> ORM configuration
  12. # Load and configure the ORM. Supports :active_record (default) and
  13. # :mongoid (bson_ext recommended) by default. Other ORMs may be
  14. # available as additional gems.
  15. require 'devise/orm/active_record'
  16. # ==> Configuration for any authentication mechanism
  17. # Configure which keys are used when authenticating a user. The default is
  18. # just :email. You can configure it to use [:username, :subdomain], so for
  19. # authenticating a user, both parameters are required. Remember that those
  20. # parameters are used only when authenticating and not when retrieving from
  21. # session. If you need permissions, you should implement that in a before filter.
  22. # You can also supply a hash where the value is a boolean determining whether
  23. # or not authentication should be aborted when the value is not present.
  24. config.authentication_keys = [ :login ]
  25. # Configure parameters from the request object used for authentication. Each entry
  26. # given should be a request method and it will automatically be passed to the
  27. # find_for_authentication method and considered in your model lookup. For instance,
  28. # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
  29. # The same considerations mentioned for authentication_keys also apply to request_keys.
  30. # config.request_keys = []
  31. # Configure which authentication keys should be case-insensitive.
  32. # These keys will be downcased upon creating or modifying a user and when used
  33. # to authenticate or find a user. Default is :email.
  34. config.case_insensitive_keys = [ :email ]
  35. # Configure which authentication keys should have whitespace stripped.
  36. # These keys will have whitespace before and after removed upon creating or
  37. # modifying a user and when used to authenticate or find a user. Default is :email.
  38. config.strip_whitespace_keys = [ :email ]
  39. # Tell if authentication through request.params is enabled. True by default.
  40. # It can be set to an array that will enable params authentication only for the
  41. # given strategies, for example, `config.params_authenticatable = [:database]` will
  42. # enable it only for database (email + password) authentication.
  43. # config.params_authenticatable = true
  44. # Tell if authentication through HTTP Basic Auth is enabled. False by default.
  45. # It can be set to an array that will enable http authentication only for the
  46. # given strategies, for example, `config.http_authenticatable = [:token]` will
  47. # enable it only for token authentication.
  48. # config.http_authenticatable = false
  49. # If http headers should be returned for AJAX requests. True by default.
  50. # config.http_authenticatable_on_xhr = true
  51. # The realm used in Http Basic Authentication. "Application" by default.
  52. # config.http_authentication_realm = "Application"
  53. # It will change confirmation, password recovery and other workflows
  54. # to behave the same regardless if the e-mail provided was right or wrong.
  55. # Does not affect registerable.
  56. # config.paranoid = true
  57. # By default Devise will store the user in session. You can skip storage for
  58. # :http_auth and :token_auth by adding those symbols to the array below.
  59. # Notice that if you are skipping storage for all authentication paths, you
  60. # may want to disable generating routes to Devise's sessions controller by
  61. # passing :skip => :sessions to `devise_for` in your config/routes.rb
  62. config.skip_session_storage = [:http_auth]
  63. # By default, Devise cleans up the CSRF token on authentication to
  64. # avoid CSRF token fixation attacks. This means that, when using AJAX
  65. # requests for sign in and sign up, you need to get a new CSRF token
  66. # from the server. You can disable this option at your own risk.
  67. # config.clean_up_csrf_token_on_authentication = true
  68. # ==> Configuration for :database_authenticatable
  69. # For bcrypt, this is the cost for hashing the password and defaults to 10. If
  70. # using other encryptors, it sets how many times you want the password re-encrypted.
  71. #
  72. # Limiting the stretches to just one in testing will increase the performance of
  73. # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
  74. # a value less than 10 in other environments.
  75. config.stretches = Rails.env.test? ? 1 : 10
  76. # Setup a pepper to generate the encrypted password.
  77. # config.pepper = "SOME LONG HASH GENERATED WITH rake secret"
  78. # ==> Configuration for :confirmable
  79. # A period that the user is allowed to access the website even without
  80. # confirming his account. For instance, if set to 2.days, the user will be
  81. # able to access the website for two days without confirming his account,
  82. # access will be blocked just in the third day. Default is 0.days, meaning
  83. # the user cannot access the website without confirming his account.
  84. # config.allow_unconfirmed_access_for = 2.days
  85. # If true, requires any email changes to be confirmed (exactly the same way as
  86. # initial account confirmation) to be applied. Requires additional unconfirmed_email
  87. # db field (see migrations). Until confirmed new email is stored in
  88. # unconfirmed email column, and copied to email column on successful confirmation.
  89. config.reconfirmable = true
  90. # Defines which key will be used when confirming an account
  91. config.confirmation_keys = [ :login ]
  92. # ==> Configuration for :rememberable
  93. # The time the user will be remembered without asking for credentials again.
  94. config.remember_for = 4.weeks
  95. # If true, extends the user's remember period when remembered via cookie.
  96. # config.extend_remember_period = false
  97. # Options to be passed to the created cookie. For instance, you can set
  98. # :secure => true in order to force SSL only cookies.
  99. if Rails.env.production?
  100. config.rememberable_options = { :secure => true }
  101. else
  102. config.rememberable_options = { }
  103. end
  104. # ==> Configuration for :validatable
  105. # Range for password length. Default is 6..128.
  106. # config.password_length = 6..128
  107. # Email regex used to validate email formats. It simply asserts that
  108. # an one (and only one) @ exists in the given string. This is mainly
  109. # to give user feedback and not to assert the e-mail validity.
  110. # config.email_regexp = /\A[^@]+@[^@]+\z/
  111. # ==> Configuration for :timeoutable
  112. # The time you want to timeout the user session without activity. After this
  113. # time the user will be asked for credentials again. Default is 30 minutes.
  114. # config.timeout_in = 30.minutes
  115. # If true, expires auth token on session timeout.
  116. # config.expire_auth_token_on_timeout = false
  117. # ==> Configuration for :lockable
  118. # Defines which strategy will be used to lock an account.
  119. # :failed_attempts = Locks an account after a number of failed attempts to sign in.
  120. # :none = No lock strategy. You should handle locking by yourself.
  121. config.lock_strategy = :failed_attempts
  122. # Defines which key will be used when locking and unlocking an account
  123. config.unlock_keys = [ :email ]
  124. # Defines which strategy will be used to unlock an account.
  125. # :email = Sends an unlock link to the user email
  126. # :time = Re-enables login after a certain amount of time (see :unlock_in below)
  127. # :both = Enables both strategies
  128. # :none = No unlock strategy. You should handle unlocking by yourself.
  129. config.unlock_strategy = :both
  130. # Number of authentication tries before locking an account if lock_strategy
  131. # is failed attempts.
  132. config.maximum_attempts = 10
  133. # Time interval to unlock the account if :time is enabled as unlock_strategy.
  134. config.unlock_in = 1.hour
  135. # ==> Configuration for :recoverable
  136. #
  137. # Defines which key will be used when recovering the password for an account
  138. config.reset_password_keys = [ :login ]
  139. # Time interval you can reset your password with a reset password key.
  140. # Don't put a too small interval or your users won't have the time to
  141. # change their passwords.
  142. config.reset_password_within = 6.hours
  143. # ==> Configuration for :encryptable
  144. # Allow you to use another encryption algorithm besides bcrypt (default). You can use
  145. # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
  146. # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
  147. # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
  148. # REST_AUTH_SITE_KEY to pepper)
  149. # config.encryptor = :sha512
  150. # ==> Scopes configuration
  151. # Turn scoped views on. Before rendering "sessions/new", it will first check for
  152. # "users/sessions/new". It's turned off by default because it's slower if you
  153. # are using only default views.
  154. # config.scoped_views = false
  155. # Configure the default scope given to Warden. By default it's the first
  156. # devise role declared in your routes (usually :user).
  157. # config.default_scope = :user
  158. # Set this configuration to false if you want /users/sign_out to sign out
  159. # only the current scope. By default, Devise signs out all scopes.
  160. # config.sign_out_all_scopes = true
  161. # ==> Navigation configuration
  162. # Lists the formats that should be treated as navigational. Formats like
  163. # :html, should redirect to the sign in page when the user does not have
  164. # access, but formats like :xml or :json, should return 401.
  165. #
  166. # If you have any extra navigational formats, like :iphone or :mobile, you
  167. # should add them to the navigational formats lists.
  168. #
  169. # The "*/*" below is required to match Internet Explorer requests.
  170. # config.navigational_formats = ["*/*", :html]
  171. # The default HTTP method used to sign out a resource. Default is :delete.
  172. config.sign_out_via = :get
  173. # ==> OmniAuth
  174. # Add a new OmniAuth provider. Check the wiki for more information on setting
  175. # up on your models and hooks.
  176. # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
  177. # ==> Warden configuration
  178. # If you want to use other strategies, that are not supported by Devise, or
  179. # change the failure app, you can configure them inside the config.warden block.
  180. #
  181. # config.warden do |manager|
  182. # manager.intercept_401 = false
  183. # manager.default_strategies(:scope => :user).unshift :some_external_strategy
  184. # end
  185. # ==> Mountable engine configurations
  186. # When using Devise inside an engine, let's call it `MyEngine`, and this engine
  187. # is mountable, there are some extra configurations to be taken into account.
  188. # The following options are available, assuming the engine is mounted as:
  189. #
  190. # mount MyEngine, at: "/my_engine"
  191. #
  192. # The router that invoked `devise_for`, in the example above, would be:
  193. # config.router_name = :my_engine
  194. #
  195. # When using omniauth, Devise cannot automatically set Omniauth path,
  196. # so you need to do it manually. For the users scope, it would be:
  197. # config.omniauth_path_prefix = "/my_engine/users/auth"
  198. end