rails_base 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +32 -0
  4. data/Rakefile +32 -0
  5. data/app/assets/config/rails_base/manifest.js +3 -0
  6. data/app/assets/images/rails_base/favicon.ico +0 -0
  7. data/app/assets/javascripts/rails_base/admin.js +2 -0
  8. data/app/assets/javascripts/rails_base/application.js +22 -0
  9. data/app/assets/javascripts/rails_base/cable.js +13 -0
  10. data/app/assets/javascripts/rails_base/mfa_auth.coffee +3 -0
  11. data/app/assets/javascripts/rails_base/secondary_authentication.coffee +3 -0
  12. data/app/assets/javascripts/rails_base/sessions.js +152 -0
  13. data/app/assets/javascripts/rails_base/user_settings.coffee +3 -0
  14. data/app/assets/stylesheets/rails_base/admin.css +4 -0
  15. data/app/assets/stylesheets/rails_base/application.scss +15 -0
  16. data/app/assets/stylesheets/rails_base/mfa_auth.scss +3 -0
  17. data/app/assets/stylesheets/rails_base/scaffolds.scss +84 -0
  18. data/app/assets/stylesheets/rails_base/secondary_authentication.scss +3 -0
  19. data/app/assets/stylesheets/rails_base/user_settings.scss +3 -0
  20. data/app/controllers/rails_base/admin_controller.rb +315 -0
  21. data/app/controllers/rails_base/application_controller.rb +153 -0
  22. data/app/controllers/rails_base/errors_controller.rb +29 -0
  23. data/app/controllers/rails_base/mfa_auth_controller.rb +50 -0
  24. data/app/controllers/rails_base/secondary_authentication_controller.rb +224 -0
  25. data/app/controllers/rails_base/switch_user_controller.rb +29 -0
  26. data/app/controllers/rails_base/user_settings_controller.rb +81 -0
  27. data/app/controllers/rails_base/users/passwords_controller.rb +19 -0
  28. data/app/controllers/rails_base/users/registrations_controller.rb +80 -0
  29. data/app/controllers/rails_base/users/sessions_controller.rb +108 -0
  30. data/app/helpers/rails_base/admin_helper.rb +107 -0
  31. data/app/helpers/rails_base/appearance_helper.rb +58 -0
  32. data/app/helpers/rails_base/application_helper.rb +26 -0
  33. data/app/helpers/rails_base/capture_reference_helper.rb +57 -0
  34. data/app/helpers/rails_base/mfa_auth_helper.rb +2 -0
  35. data/app/helpers/rails_base/secondary_authentication_helper.rb +2 -0
  36. data/app/helpers/rails_base/user_field_validators.rb +108 -0
  37. data/app/helpers/rails_base/user_settings_helper.rb +22 -0
  38. data/app/jobs/rails_base/application_job.rb +10 -0
  39. data/app/jobs/twilio_job.rb +9 -0
  40. data/app/mailers/rails_base/application_mailer.rb +9 -0
  41. data/app/mailers/rails_base/email_verification_mailer.rb +22 -0
  42. data/app/mailers/rails_base/event_mailer.rb +16 -0
  43. data/app/models/admin_action.rb +119 -0
  44. data/app/models/rails_base/application_record.rb +22 -0
  45. data/app/models/rails_base/user_constants.rb +28 -0
  46. data/app/models/secret.rb +37 -0
  47. data/app/models/short_lived_data.rb +132 -0
  48. data/app/models/user.rb +143 -0
  49. data/app/services/rails_base/admin_risky_mfa_send.rb +80 -0
  50. data/app/services/rails_base/admin_update_attribute.rb +100 -0
  51. data/app/services/rails_base/authentication/authenticate_user.rb +28 -0
  52. data/app/services/rails_base/authentication/constants.rb +60 -0
  53. data/app/services/rails_base/authentication/decision_twofa_type.rb +76 -0
  54. data/app/services/rails_base/authentication/destroy_user.rb +45 -0
  55. data/app/services/rails_base/authentication/mfa_set_encrypt_token.rb +32 -0
  56. data/app/services/rails_base/authentication/mfa_validator.rb +88 -0
  57. data/app/services/rails_base/authentication/modify_password.rb +67 -0
  58. data/app/services/rails_base/authentication/send_forgot_password.rb +26 -0
  59. data/app/services/rails_base/authentication/send_login_mfa_to_user.rb +77 -0
  60. data/app/services/rails_base/authentication/send_verification_email.rb +103 -0
  61. data/app/services/rails_base/authentication/session_token_verifier.rb +31 -0
  62. data/app/services/rails_base/authentication/single_sign_on_create.rb +44 -0
  63. data/app/services/rails_base/authentication/single_sign_on_send.rb +101 -0
  64. data/app/services/rails_base/authentication/single_sign_on_verify.rb +42 -0
  65. data/app/services/rails_base/authentication/sso_verify_email.rb +43 -0
  66. data/app/services/rails_base/authentication/update_phone_send_verification.rb +46 -0
  67. data/app/services/rails_base/authentication/verify_forgot_password.rb +46 -0
  68. data/app/services/rails_base/email_change.rb +20 -0
  69. data/app/services/rails_base/encryption.rb +87 -0
  70. data/app/services/rails_base/name_change.rb +71 -0
  71. data/app/services/rails_base/service_base.rb +65 -0
  72. data/app/services/rails_base/service_logging.rb +23 -0
  73. data/app/views/layouts/rails_base/application.html.erb +185 -0
  74. data/app/views/layouts/rails_base/mailer.html.erb +13 -0
  75. data/app/views/layouts/rails_base/mailer.text.erb +1 -0
  76. data/app/views/new.html.erb +4 -0
  77. data/app/views/rails_base/admin/history.html.erb +26 -0
  78. data/app/views/rails_base/admin/index.html.erb +149 -0
  79. data/app/views/rails_base/admin/show_config.html.erb +18 -0
  80. data/app/views/rails_base/devise/confirmations/new.html.erb +16 -0
  81. data/app/views/rails_base/devise/mailer/confirmation_instructions.html.erb +5 -0
  82. data/app/views/rails_base/devise/mailer/email_changed.html.erb +7 -0
  83. data/app/views/rails_base/devise/mailer/password_change.html.erb +3 -0
  84. data/app/views/rails_base/devise/mailer/reset_password_instructions.html.erb +8 -0
  85. data/app/views/rails_base/devise/mailer/unlock_instructions.html.erb +7 -0
  86. data/app/views/rails_base/devise/passwords/edit.html.erb +25 -0
  87. data/app/views/rails_base/devise/passwords/new.html.erb +27 -0
  88. data/app/views/rails_base/devise/registrations/edit.html.erb +43 -0
  89. data/app/views/rails_base/devise/registrations/new.html.erb +123 -0
  90. data/app/views/rails_base/devise/sessions/new.html.erb +4 -0
  91. data/app/views/rails_base/devise/shared/_error_messages.html.erb +15 -0
  92. data/app/views/rails_base/devise/shared/_links.html.erb +25 -0
  93. data/app/views/rails_base/devise/unlocks/new.html.erb +16 -0
  94. data/app/views/rails_base/email_verification_mailer/email_verification.html.erb +25 -0
  95. data/app/views/rails_base/email_verification_mailer/event.html.erb +20 -0
  96. data/app/views/rails_base/email_verification_mailer/forgot_password.html.erb +22 -0
  97. data/app/views/rails_base/errors/internal_error.html.erb +1 -0
  98. data/app/views/rails_base/errors/not_found.html.erb +1 -0
  99. data/app/views/rails_base/errors/unacceptable.html.erb +1 -0
  100. data/app/views/rails_base/event_mailer/event.html.erb +10 -0
  101. data/app/views/rails_base/mfa_auth/mfa_code.html.erb +10 -0
  102. data/app/views/rails_base/secondary_authentication/after_email_login_session_new.html.erb +3 -0
  103. data/app/views/rails_base/secondary_authentication/forgot_password.html.erb +9 -0
  104. data/app/views/rails_base/secondary_authentication/remove_me.html.erb +1 -0
  105. data/app/views/rails_base/secondary_authentication/static.html.erb +5 -0
  106. data/app/views/rails_base/shared/_admin_actions_modal.html.erb +65 -0
  107. data/app/views/rails_base/shared/_admin_config_class.html.erb +52 -0
  108. data/app/views/rails_base/shared/_admin_history.html.erb +86 -0
  109. data/app/views/rails_base/shared/_admin_modify_email.html.erb +78 -0
  110. data/app/views/rails_base/shared/_admin_modify_name.html.erb +107 -0
  111. data/app/views/rails_base/shared/_admin_modify_phone.html.erb +87 -0
  112. data/app/views/rails_base/shared/_admin_modify_text.html.erb +35 -0
  113. data/app/views/rails_base/shared/_admin_risky_change.html.erb +57 -0
  114. data/app/views/rails_base/shared/_admin_risky_mfa.html.erb +74 -0
  115. data/app/views/rails_base/shared/_admin_selector_dropdown.html.erb +70 -0
  116. data/app/views/rails_base/shared/_admin_toggle_button.html.erb +72 -0
  117. data/app/views/rails_base/shared/_admin_warning_alert.html.erb +7 -0
  118. data/app/views/rails_base/shared/_appearance_mode_selector.html.erb +183 -0
  119. data/app/views/rails_base/shared/_custom_form_validation_javascript.html.erb +129 -0
  120. data/app/views/rails_base/shared/_enable_mfa_auth_modal.html.erb +105 -0
  121. data/app/views/rails_base/shared/_error_pages.html.erb +123 -0
  122. data/app/views/rails_base/shared/_logged_in_header.html.erb +123 -0
  123. data/app/views/rails_base/shared/_logged_out_header.html.erb +14 -0
  124. data/app/views/rails_base/shared/_mfa_input_layout.html.erb +5 -0
  125. data/app/views/rails_base/shared/_mfa_input_layout_default.html.erb +97 -0
  126. data/app/views/rails_base/shared/_mfa_input_layout_fallback.html.erb +55 -0
  127. data/app/views/rails_base/shared/_modify_mfa_auth_modal.html.erb +20 -0
  128. data/app/views/rails_base/shared/_password_confirm_javascript.html.erb +71 -0
  129. data/app/views/rails_base/shared/_reset_password_form.html.erb +111 -0
  130. data/app/views/rails_base/shared/_session_create_form.html.erb +32 -0
  131. data/app/views/rails_base/shared/_session_timeout_modal.html.erb +76 -0
  132. data/app/views/rails_base/switch_user/_widget.html.erb +5 -0
  133. data/app/views/rails_base/user_settings/_confirm_destroy_user.html.erb +42 -0
  134. data/app/views/rails_base/user_settings/_destroy_user.html.erb +106 -0
  135. data/app/views/rails_base/user_settings/_modify_name.html.erb +71 -0
  136. data/app/views/rails_base/user_settings/_modify_password.html.erb +101 -0
  137. data/app/views/rails_base/user_settings/_modify_password_update_password.html.erb +2 -0
  138. data/app/views/rails_base/user_settings/index.html.erb +54 -0
  139. data/config/initializers/01_rails_config.rb +19 -0
  140. data/config/initializers/admin_action_helper.rb +88 -0
  141. data/config/initializers/browser.rb +4 -0
  142. data/config/initializers/default_logged_in_headers.rb +23 -0
  143. data/config/initializers/devise.rb +314 -0
  144. data/config/initializers/encryption.rb +2 -0
  145. data/config/initializers/switch_user.rb +58 -0
  146. data/config/initializers/switch_user_helper.rb +29 -0
  147. data/config/locales/devise.en.yml +65 -0
  148. data/config/locales/en.yml +58 -0
  149. data/config/routes.rb +114 -0
  150. data/db/migrate/20210212175453_devise_create_rails_base_users.rb +56 -0
  151. data/db/migrate/20210212190537_create_rails_base_short_lived_data.rb +19 -0
  152. data/db/migrate/20210212192645_create_rails_base_secrets.rb +11 -0
  153. data/db/migrate/20210406015744_create_rails_base_admin_actions.rb +17 -0
  154. data/db/seeds.rb +23 -0
  155. data/lib/link_decision_helper.rb +71 -0
  156. data/lib/rails_base.rb +50 -0
  157. data/lib/rails_base/admin/action_cache.rb +99 -0
  158. data/lib/rails_base/admin/action_helper.rb +134 -0
  159. data/lib/rails_base/admin/default_index_tile.rb +176 -0
  160. data/lib/rails_base/admin/index_tile.rb +186 -0
  161. data/lib/rails_base/config.rb +52 -0
  162. data/lib/rails_base/configuration/active_job.rb +38 -0
  163. data/lib/rails_base/configuration/admin.rb +231 -0
  164. data/lib/rails_base/configuration/app.rb +52 -0
  165. data/lib/rails_base/configuration/appearance.rb +131 -0
  166. data/lib/rails_base/configuration/authentication.rb +37 -0
  167. data/lib/rails_base/configuration/base.rb +209 -0
  168. data/lib/rails_base/configuration/display/background_color.rb +25 -0
  169. data/lib/rails_base/configuration/display/btn_danger.rb +25 -0
  170. data/lib/rails_base/configuration/display/btn_dark.rb +25 -0
  171. data/lib/rails_base/configuration/display/btn_info.rb +25 -0
  172. data/lib/rails_base/configuration/display/btn_light.rb +25 -0
  173. data/lib/rails_base/configuration/display/btn_primary.rb +25 -0
  174. data/lib/rails_base/configuration/display/btn_secondary.rb +25 -0
  175. data/lib/rails_base/configuration/display/btn_success.rb +25 -0
  176. data/lib/rails_base/configuration/display/btn_warning.rb +25 -0
  177. data/lib/rails_base/configuration/display/footer.rb +54 -0
  178. data/lib/rails_base/configuration/display/navbar.rb +25 -0
  179. data/lib/rails_base/configuration/display/table_body.rb +25 -0
  180. data/lib/rails_base/configuration/display/table_header.rb +25 -0
  181. data/lib/rails_base/configuration/display/text.rb +26 -0
  182. data/lib/rails_base/configuration/exceptions_app.rb +25 -0
  183. data/lib/rails_base/configuration/login_behavior.rb +17 -0
  184. data/lib/rails_base/configuration/mailer.rb +116 -0
  185. data/lib/rails_base/configuration/mfa.rb +84 -0
  186. data/lib/rails_base/configuration/owner.rb +17 -0
  187. data/lib/rails_base/configuration/redis.rb +29 -0
  188. data/lib/rails_base/configuration/user.rb +43 -0
  189. data/lib/rails_base/engine.rb +51 -0
  190. data/lib/rails_base/version.rb +10 -0
  191. data/lib/tasks/rails_base_tasks.rake +4 -0
  192. data/lib/twilio_helper.rb +26 -0
  193. data/lib/velocity_limiter.rb +91 -0
  194. metadata +619 -0
@@ -0,0 +1,54 @@
1
+ <div class="row">
2
+ <div class="col-md-10 offset-md-1">
3
+ <div class="row">
4
+ <table class="table table-striped table-bordered">
5
+ <tbody class="thead-dark">
6
+ <tr>
7
+ <th scope="col" class='text-right' style="width: 40%">
8
+ Full Name
9
+ </th>
10
+ <td style="width: 40%">
11
+ <%= current_user.full_name %>
12
+ </td>
13
+ <td style="width: 20%">
14
+ <button class="btn btn_primary btn-block show-create-modal" data-toggle="modal" data-target="#modifyNameModal" type="button">Modify</button>
15
+ </td>
16
+ </tr>
17
+ <tr>
18
+ <th scope="col" class='text-right' style="width: 40%">
19
+ MFA enabled?
20
+ </th>
21
+ <td style="width: 40%">
22
+ <%= current_user.mfa_enabled %>
23
+ </td>
24
+ <td style="width: 20%">
25
+ <button class="btn btn_primary btn-block show-create-modal" type="button">Modify</button>
26
+ </td>
27
+ </tr>
28
+ <tr>
29
+ <th scope="col" class='text-right' style="width: 40%">
30
+ Password
31
+ </th>
32
+ <td style="width: 40%">
33
+ <%= "<redacted>" %>
34
+ </td>
35
+ <td style="width: 20%">
36
+ <button class="btn btn_primary btn-block show-create-modal" type="button" data-toggle="modal" data-target="#modifyPasswordModal">Modify</button>
37
+ </td>
38
+ </tr>
39
+ </tbody>
40
+ </table>
41
+ </div>
42
+ <div class="row" style="margin-top: 50px">
43
+ <button type="button" class="btn btn_danger btn-block" data-toggle="modal" data-target="#destroyUserModal">
44
+ Destroy account
45
+ </button>
46
+ </div>
47
+ </div>
48
+ </div>
49
+
50
+
51
+ <%= render 'modify_name' %>
52
+ <%= render 'modify_password' %>
53
+ <%= render 'destroy_user' %>
54
+
@@ -0,0 +1,19 @@
1
+ ####################################################
2
+ # File is prepended with 01 so that it loads first #
3
+ ####################################################
4
+
5
+ require 'link_decision_helper'
6
+
7
+ Rails.application.configure do
8
+ # Ensure that RailBase assets get compiled
9
+ config.assets.precompile << 'rails_base/manifest'
10
+
11
+ # ToDo: Move this to a configuration similar to admin tiles
12
+ #################################
13
+ # Define logged in Header paths #
14
+ #################################
15
+ LinkDecisionHelper::ALLOWED_TYPES.each do |type|
16
+ thing = config.public_send("#{type} ||=", [])
17
+ config.public_send("#{type}=", []) if thing.empty?
18
+ end
19
+ end
@@ -0,0 +1,88 @@
1
+ require 'rails_base/admin/action_helper'
2
+
3
+ proc = Proc.new do |req, params, admin_user, user, title, struct|
4
+ actions_mapping = {
5
+ index: 'Viewed Settings page',
6
+ edit_name: 'Modified name',
7
+ edit_password: 'Modified Password',
8
+ destroy_user: '!Destroyed User!'
9
+ }
10
+
11
+ if actions_mapping.keys.include?(params[:action].to_sym)
12
+ {
13
+ admin_user: admin_user,
14
+ user: user,
15
+ action: actions_mapping[params[:action].to_sym] ,
16
+ original_attribute: struct&.original_attribute,
17
+ new_attribute: struct&.new_attribute
18
+ }
19
+ else
20
+ nil
21
+ end
22
+ end
23
+ # For all User Settings routes
24
+ params = {
25
+ proc: proc,
26
+ controller: RailsBase::UserSettingsController,
27
+ default: true
28
+ }
29
+ RailsBase::Admin::ActionHelper.new(**params).add!
30
+
31
+
32
+ proc = Proc.new do |req, params, admin_user, user, title, struct|
33
+ actions_mapping = {
34
+ update_attribute: "Updated [#{params[:attribute]}]",
35
+ update_name: 'Updated Name',
36
+ update_email: 'Updated Email',
37
+ update_phone: 'Updated Phone number',
38
+ index: 'Viewed Admin Index',
39
+ sso_send: 'Sent SSO to user'
40
+ }
41
+
42
+ if actions_mapping.keys.include?(params[:action].to_sym)
43
+ {
44
+ admin_user: admin_user,
45
+ user: struct&.user,
46
+ action: actions_mapping[params[:action].to_sym],
47
+ original_attribute: struct&.original_attribute,
48
+ new_attribute: struct&.new_attribute
49
+ }
50
+ else
51
+ nil
52
+ end
53
+ end
54
+ # For all Admin routes
55
+ params = {
56
+ proc: proc,
57
+ controller: RailsBase::AdminController,
58
+ default: true
59
+ }
60
+ RailsBase::Admin::ActionHelper.new(**params).add!
61
+
62
+
63
+ params = {
64
+ proc: nil,
65
+ title: 'Removed Phone from account',
66
+ controller: RailsBase::SecondaryAuthenticationController,
67
+ action: 'remove_phone_mfa',
68
+ default: true
69
+ }
70
+ RailsBase::Admin::ActionHelper.new(**params).add!
71
+
72
+ params = {
73
+ proc: nil,
74
+ title: 'Setting Phone on account',
75
+ controller: RailsBase::SecondaryAuthenticationController,
76
+ action: 'phone_registration',
77
+ default: true
78
+ }
79
+ RailsBase::Admin::ActionHelper.new(**params).add!
80
+
81
+ params = {
82
+ proc: nil,
83
+ title: 'Impersonation',
84
+ controller: RailsBase::SwitchUserController,
85
+ action: 'set_current_user',
86
+ default: true
87
+ }
88
+ RailsBase::Admin::ActionHelper.new(**params).add!
@@ -0,0 +1,4 @@
1
+ require 'browser'
2
+ require 'browser/aliases'
3
+
4
+ Browser::Base.include(Browser::Aliases)
@@ -0,0 +1,23 @@
1
+ params = {
2
+ title: 'Admin',
3
+ url: -> { Rails.application.routes.url_helpers.admin_base_path },
4
+ type: LinkDecisionHelper::NAVBAR_LOGGED_IN,
5
+ display: ->(current_user) { RailsBase.config.admin.view_admin_page?(current_user) }
6
+ }
7
+ LinkDecisionHelper.new(**params).assign!
8
+
9
+ params = {
10
+ title: 'Admin History',
11
+ url: -> { Rails.application.routes.url_helpers.admin_history_path },
12
+ display: -> (current_user) { RailsBase.config.admin.enable_history_by_user?(current_user) } ,
13
+ type: LinkDecisionHelper::NAVBAR_LOGGED_IN,
14
+ }
15
+ LinkDecisionHelper.new(**params).assign!
16
+
17
+ params = {
18
+ title: 'Admin Config',
19
+ url: -> { Rails.application.routes.url_helpers.admin_config_path },
20
+ display: -> (current_user) { RailsBase.config.admin.config_page?(current_user) } ,
21
+ type: LinkDecisionHelper::NAVBAR_LOGGED_IN,
22
+ }
23
+ LinkDecisionHelper.new(**params).assign!
@@ -0,0 +1,314 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'devise'
4
+
5
+ # Assuming you have not yet modified this file, each configuration option below
6
+ # is set to its default value. Note that some are commented out while others
7
+ # are not: uncommented lines are intended to protect your configuration from
8
+ # breaking changes in upgrades (i.e., in the event that future versions of
9
+ # Devise change the default values for those options).
10
+ #
11
+ # Use this hook to configure devise mailer, warden hooks and so forth.
12
+ # Many of these configuration options can be set straight in your model.
13
+ Devise.setup do |config|
14
+ # The secret key used by Devise. Devise uses this key to generate
15
+ # random tokens. Changing this key will render invalid all existing
16
+ # confirmation, reset password and unlock tokens in the database.
17
+ # Devise will use the `secret_key_base` as its `secret_key`
18
+ # by default. You can change it below and use your own secret key.
19
+ config.secret_key = 'b3084c41135fc690aca7762992713d23f7dd4e0651dfee05898ecc69a5a7246b0838e1bc1874a9f9c2d4e90d0b706774113fe5a382263870d20a99729e78defd'
20
+
21
+ # ==> Controller configuration
22
+ # Configure the parent class to the devise controllers.
23
+ # config.parent_controller = 'DeviseController'
24
+
25
+ # ==> Mailer Configuration
26
+ # Configure the e-mail address which will be shown in Devise::Mailer,
27
+ # note that it will be overwritten if you use your own mailer class
28
+ # with default "from" parameter.
29
+ # config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
30
+
31
+ # Configure the class responsible to send e-mails.
32
+ # config.mailer = 'Devise::Mailer'
33
+
34
+ # Configure the parent class responsible to send e-mails.
35
+ # config.parent_mailer = 'ActionMailer::Base'
36
+
37
+ # ==> ORM configuration
38
+ # Load and configure the ORM. Supports :active_record (default) and
39
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
40
+ # available as additional gems.
41
+ require 'devise/orm/active_record'
42
+
43
+ # ==> Configuration for any authentication mechanism
44
+ # Configure which keys are used when authenticating a user. The default is
45
+ # just :email. You can configure it to use [:username, :subdomain], so for
46
+ # authenticating a user, both parameters are required. Remember that those
47
+ # parameters are used only when authenticating and not when retrieving from
48
+ # session. If you need permissions, you should implement that in a before filter.
49
+ # You can also supply a hash where the value is a boolean determining whether
50
+ # or not authentication should be aborted when the value is not present.
51
+ # config.authentication_keys = [:email]
52
+
53
+ # Configure parameters from the request object used for authentication. Each entry
54
+ # given should be a request method and it will automatically be passed to the
55
+ # find_for_authentication method and considered in your model lookup. For instance,
56
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
57
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
58
+ # config.request_keys = []
59
+
60
+ # Configure which authentication keys should be case-insensitive.
61
+ # These keys will be downcased upon creating or modifying a user and when used
62
+ # to authenticate or find a user. Default is :email.
63
+ config.case_insensitive_keys = [:email]
64
+
65
+ # Configure which authentication keys should have whitespace stripped.
66
+ # These keys will have whitespace before and after removed upon creating or
67
+ # modifying a user and when used to authenticate or find a user. Default is :email.
68
+ config.strip_whitespace_keys = [:email]
69
+
70
+ # Tell if authentication through request.params is enabled. True by default.
71
+ # It can be set to an array that will enable params authentication only for the
72
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
73
+ # enable it only for database (email + password) authentication.
74
+ # config.params_authenticatable = true
75
+
76
+ # Tell if authentication through HTTP Auth is enabled. False by default.
77
+ # It can be set to an array that will enable http authentication only for the
78
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
79
+ # enable it only for database authentication.
80
+ # For API-only applications to support authentication "out-of-the-box", you will likely want to
81
+ # enable this with :database unless you are using a custom strategy.
82
+ # The supported strategies are:
83
+ # :database = Support basic authentication with authentication key + password
84
+ # config.http_authenticatable = false
85
+
86
+ # If 401 status code should be returned for AJAX requests. True by default.
87
+ # config.http_authenticatable_on_xhr = true
88
+
89
+ # The realm used in Http Basic Authentication. 'Application' by default.
90
+ # config.http_authentication_realm = 'Application'
91
+
92
+ # It will change confirmation, password recovery and other workflows
93
+ # to behave the same regardless if the e-mail provided was right or wrong.
94
+ # Does not affect registerable.
95
+ # config.paranoid = true
96
+
97
+ # By default Devise will store the user in session. You can skip storage for
98
+ # particular strategies by setting this option.
99
+ # Notice that if you are skipping storage for all authentication paths, you
100
+ # may want to disable generating routes to Devise's sessions controller by
101
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
102
+ config.skip_session_storage = [:http_auth]
103
+
104
+ # By default, Devise cleans up the CSRF token on authentication to
105
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
106
+ # requests for sign in and sign up, you need to get a new CSRF token
107
+ # from the server. You can disable this option at your own risk.
108
+ # config.clean_up_csrf_token_on_authentication = true
109
+
110
+ # When false, Devise will not attempt to reload routes on eager load.
111
+ # This can reduce the time taken to boot the app but if your application
112
+ # requires the Devise mappings to be loaded during boot time the application
113
+ # won't boot properly.
114
+ # config.reload_routes = true
115
+
116
+ # ==> Configuration for :database_authenticatable
117
+ # For bcrypt, this is the cost for hashing the password and defaults to 12. If
118
+ # using other algorithms, it sets how many times you want the password to be hashed.
119
+ # The number of stretches used for generating the hashed password are stored
120
+ # with the hashed password. This allows you to change the stretches without
121
+ # invalidating existing passwords.
122
+ #
123
+ # Limiting the stretches to just one in testing will increase the performance of
124
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
125
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
126
+ # algorithm), the cost increases exponentially with the number of stretches (e.g.
127
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
128
+ config.stretches = Rails.env.test? ? 1 : 12
129
+
130
+ # Set up a pepper to generate the hashed password.
131
+ # config.pepper = '0fe48c1e4692ce142252f61212c326fe3b380ad43b95faa012e5e95a59e9b68fb8ad65301aa4ef2500b7d558de0e037e09f3cb8c4b22001b99e91bcd34efdf3e'
132
+
133
+ # Send a notification to the original email when the user's email is changed.
134
+ # config.send_email_changed_notification = false
135
+
136
+ # Send a notification email when the user's password is changed.
137
+ # config.send_password_change_notification = false
138
+
139
+ # ==> Configuration for :confirmable
140
+ # A period that the user is allowed to access the website even without
141
+ # confirming their account. For instance, if set to 2.days, the user will be
142
+ # able to access the website for two days without confirming their account,
143
+ # access will be blocked just in the third day.
144
+ # You can also set it to nil, which will allow the user to access the website
145
+ # without confirming their account.
146
+ # Default is 0.days, meaning the user cannot access the website without
147
+ # confirming their account.
148
+ # config.allow_unconfirmed_access_for = 2.days
149
+
150
+ # A period that the user is allowed to confirm their account before their
151
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
152
+ # their account within 3 days after the mail was sent, but on the fourth day
153
+ # their account can't be confirmed with the token any more.
154
+ # Default is nil, meaning there is no restriction on how long a user can take
155
+ # before confirming their account.
156
+ # config.confirm_within = 3.days
157
+
158
+ # If true, requires any email changes to be confirmed (exactly the same way as
159
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
160
+ # db field (see migrations). Until confirmed, new email is stored in
161
+ # unconfirmed_email column, and copied to email column on successful confirmation.
162
+ config.reconfirmable = true
163
+
164
+ # Defines which key will be used when confirming an account
165
+ # config.confirmation_keys = [:email]
166
+
167
+ # ==> Configuration for :rememberable
168
+ # The time the user will be remembered without asking for credentials again.
169
+ # config.remember_for = 2.weeks
170
+
171
+ # Invalidates all the remember me tokens when the user signs out.
172
+ config.expire_all_remember_me_on_sign_out = true
173
+
174
+ # If true, extends the user's remember period when remembered via cookie.
175
+ # config.extend_remember_period = false
176
+
177
+ # Options to be passed to the created cookie. For instance, you can set
178
+ # secure: true in order to force SSL only cookies.
179
+ # config.rememberable_options = {}
180
+
181
+ # ==> Configuration for :validatable
182
+ # Range for password length.
183
+ config.password_length = 6..128
184
+
185
+ # Email regex used to validate email formats. It simply asserts that
186
+ # one (and only one) @ exists in the given string. This is mainly
187
+ # to give user feedback and not to assert the e-mail validity.
188
+ config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
189
+
190
+ # ==> Configuration for :timeoutable
191
+ # The time you want to timeout the user session without activity. After this
192
+ # time the user will be asked for credentials again. Default is 30 minutes.
193
+ # Timout gets assigned dynamically via RailsBase.config.auth.session_timeout
194
+ # config.timeout_in = Rails.configuration.session_timeout
195
+
196
+ # ==> Configuration for :lockable
197
+ # Defines which strategy will be used to lock an account.
198
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
199
+ # :none = No lock strategy. You should handle locking by yourself.
200
+ # config.lock_strategy = :failed_attempts
201
+
202
+ # Defines which key will be used when locking and unlocking an account
203
+ # config.unlock_keys = [:email]
204
+
205
+ # Defines which strategy will be used to unlock an account.
206
+ # :email = Sends an unlock link to the user email
207
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
208
+ # :both = Enables both strategies
209
+ # :none = No unlock strategy. You should handle unlocking by yourself.
210
+ # config.unlock_strategy = :both
211
+
212
+ # Number of authentication tries before locking an account if lock_strategy
213
+ # is failed attempts.
214
+ # config.maximum_attempts = 20
215
+
216
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
217
+ # config.unlock_in = 1.hour
218
+
219
+ # Warn on the last attempt before the account is locked.
220
+ # config.last_attempt_warning = true
221
+
222
+ # ==> Configuration for :recoverable
223
+ #
224
+ # Defines which key will be used when recovering the password for an account
225
+ # config.reset_password_keys = [:email]
226
+
227
+ # Time interval you can reset your password with a reset password key.
228
+ # Don't put a too small interval or your users won't have the time to
229
+ # change their passwords.
230
+ config.reset_password_within = 6.hours
231
+
232
+ # When set to false, does not sign a user in automatically after their password is
233
+ # reset. Defaults to true, so a user is signed in automatically after a reset.
234
+ # config.sign_in_after_reset_password = true
235
+
236
+ # ==> Configuration for :encryptable
237
+ # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
238
+ # You can use :sha1, :sha512 or algorithms from others authentication tools as
239
+ # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
240
+ # for default behavior) and :restful_authentication_sha1 (then you should set
241
+ # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
242
+ #
243
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
244
+ # config.encryptor = :sha512
245
+
246
+ # ==> Scopes configuration
247
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
248
+ # "users/sessions/new". It's turned off by default because it's slower if you
249
+ # are using only default views.
250
+ # config.scoped_views = false
251
+
252
+ # Configure the default scope given to Warden. By default it's the first
253
+ # devise role declared in your routes (usually :user).
254
+ # config.default_scope = :user
255
+
256
+ # Set this configuration to false if you want /users/sign_out to sign out
257
+ # only the current scope. By default, Devise signs out all scopes.
258
+ # config.sign_out_all_scopes = true
259
+
260
+ # ==> Navigation configuration
261
+ # Lists the formats that should be treated as navigational. Formats like
262
+ # :html, should redirect to the sign in page when the user does not have
263
+ # access, but formats like :xml or :json, should return 401.
264
+ #
265
+ # If you have any extra navigational formats, like :iphone or :mobile, you
266
+ # should add them to the navigational formats lists.
267
+ #
268
+ # The "*/*" below is required to match Internet Explorer requests.
269
+ # config.navigational_formats = ['*/*', :html]
270
+
271
+ # The default HTTP method used to sign out a resource. Default is :delete.
272
+ config.sign_out_via = :delete
273
+
274
+ # ==> OmniAuth
275
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
276
+ # up on your models and hooks.
277
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
278
+
279
+ # ==> Warden configuration
280
+ # If you want to use other strategies, that are not supported by Devise, or
281
+ # change the failure app, you can configure them inside the config.warden block.
282
+ #
283
+ # config.warden do |manager|
284
+ # manager.intercept_401 = false
285
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
286
+ # end
287
+
288
+ # ==> Mountable engine configurations
289
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
290
+ # is mountable, there are some extra configurations to be taken into account.
291
+ # The following options are available, assuming the engine is mounted as:
292
+ #
293
+ # mount MyEngine, at: '/my_engine'
294
+ #
295
+ # The router that invoked `devise_for`, in the example above, would be:
296
+ config.router_name = :rails_base
297
+ #
298
+ # When using OmniAuth, Devise cannot automatically set OmniAuth path,
299
+ # so you need to do it manually. For the users scope, it would be:
300
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
301
+
302
+ # ==> Turbolinks configuration
303
+ # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
304
+ #
305
+ # ActiveSupport.on_load(:devise_failure_app) do
306
+ # include Turbolinks::Controller
307
+ # end
308
+
309
+ # ==> Configuration for :registerable
310
+
311
+ # When set to false, does not sign a user in automatically after their password is
312
+ # changed. Defaults to true, so a user is signed in automatically after changing a password.
313
+ # config.sign_in_after_change_password = true
314
+ end