sorcery 0.11.0 → 0.15.1

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 (106) hide show
  1. checksums.yaml +5 -5
  2. data/.github/ISSUE_TEMPLATE.md +20 -0
  3. data/.rubocop.yml +55 -0
  4. data/.rubocop_todo.yml +145 -0
  5. data/.travis.yml +3 -52
  6. data/CHANGELOG.md +69 -0
  7. data/Gemfile +3 -3
  8. data/{LICENSE.txt → LICENSE.md} +1 -1
  9. data/README.md +34 -7
  10. data/lib/generators/sorcery/USAGE +1 -1
  11. data/lib/generators/sorcery/install_generator.rb +21 -21
  12. data/lib/generators/sorcery/templates/initializer.rb +164 -69
  13. data/lib/generators/sorcery/templates/migration/activity_logging.rb +4 -4
  14. data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +3 -3
  15. data/lib/generators/sorcery/templates/migration/core.rb +2 -2
  16. data/lib/generators/sorcery/templates/migration/external.rb +3 -3
  17. data/lib/generators/sorcery/templates/migration/magic_login.rb +9 -0
  18. data/lib/generators/sorcery/templates/migration/remember_me.rb +2 -2
  19. data/lib/generators/sorcery/templates/migration/reset_password.rb +4 -3
  20. data/lib/generators/sorcery/templates/migration/user_activation.rb +3 -3
  21. data/lib/sorcery.rb +2 -0
  22. data/lib/sorcery/adapters/active_record_adapter.rb +3 -2
  23. data/lib/sorcery/adapters/mongoid_adapter.rb +23 -11
  24. data/lib/sorcery/controller.rb +26 -15
  25. data/lib/sorcery/controller/config.rb +2 -0
  26. data/lib/sorcery/controller/submodules/activity_logging.rb +14 -3
  27. data/lib/sorcery/controller/submodules/brute_force_protection.rb +7 -3
  28. data/lib/sorcery/controller/submodules/external.rb +48 -33
  29. data/lib/sorcery/controller/submodules/http_basic_auth.rb +5 -1
  30. data/lib/sorcery/controller/submodules/remember_me.rb +9 -10
  31. data/lib/sorcery/controller/submodules/session_timeout.rb +32 -6
  32. data/lib/sorcery/crypto_providers/aes256.rb +2 -1
  33. data/lib/sorcery/crypto_providers/bcrypt.rb +8 -2
  34. data/lib/sorcery/engine.rb +16 -3
  35. data/lib/sorcery/model.rb +14 -10
  36. data/lib/sorcery/model/config.rb +12 -4
  37. data/lib/sorcery/model/submodules/brute_force_protection.rb +6 -7
  38. data/lib/sorcery/model/submodules/external.rb +19 -3
  39. data/lib/sorcery/model/submodules/magic_login.rb +130 -0
  40. data/lib/sorcery/model/submodules/reset_password.rb +25 -2
  41. data/lib/sorcery/model/submodules/user_activation.rb +1 -1
  42. data/lib/sorcery/model/temporary_token.rb +3 -1
  43. data/lib/sorcery/protocols/oauth.rb +1 -0
  44. data/lib/sorcery/providers/auth0.rb +46 -0
  45. data/lib/sorcery/providers/discord.rb +52 -0
  46. data/lib/sorcery/providers/heroku.rb +1 -0
  47. data/lib/sorcery/providers/instagram.rb +73 -0
  48. data/lib/sorcery/providers/line.rb +47 -0
  49. data/lib/sorcery/providers/linkedin.rb +45 -36
  50. data/lib/sorcery/providers/vk.rb +5 -4
  51. data/lib/sorcery/providers/wechat.rb +8 -6
  52. data/lib/sorcery/test_helpers/internal.rb +5 -4
  53. data/lib/sorcery/test_helpers/internal/rails.rb +11 -11
  54. data/lib/sorcery/test_helpers/rails/request.rb +20 -0
  55. data/lib/sorcery/version.rb +1 -1
  56. data/sorcery.gemspec +28 -11
  57. data/spec/active_record/user_activation_spec.rb +2 -2
  58. data/spec/active_record/user_activity_logging_spec.rb +2 -2
  59. data/spec/active_record/user_brute_force_protection_spec.rb +2 -2
  60. data/spec/active_record/user_magic_login_spec.rb +15 -0
  61. data/spec/active_record/user_oauth_spec.rb +2 -2
  62. data/spec/active_record/user_remember_me_spec.rb +2 -2
  63. data/spec/active_record/user_reset_password_spec.rb +2 -2
  64. data/spec/active_record/user_spec.rb +0 -10
  65. data/spec/controllers/controller_http_basic_auth_spec.rb +1 -1
  66. data/spec/controllers/controller_oauth2_spec.rb +212 -123
  67. data/spec/controllers/controller_oauth_spec.rb +7 -7
  68. data/spec/controllers/controller_remember_me_spec.rb +16 -8
  69. data/spec/controllers/controller_session_timeout_spec.rb +90 -3
  70. data/spec/controllers/controller_spec.rb +13 -3
  71. data/spec/orm/active_record.rb +2 -2
  72. data/spec/providers/example_provider_spec.rb +17 -0
  73. data/spec/providers/example_spec.rb +17 -0
  74. data/spec/providers/vk_spec.rb +42 -0
  75. data/spec/rails_app/app/assets/config/manifest.js +1 -0
  76. data/spec/rails_app/app/controllers/sorcery_controller.rb +131 -32
  77. data/spec/rails_app/app/mailers/sorcery_mailer.rb +7 -0
  78. data/spec/rails_app/app/views/sorcery_mailer/magic_login_email.html.erb +13 -0
  79. data/spec/rails_app/app/views/sorcery_mailer/magic_login_email.text.erb +6 -0
  80. data/spec/rails_app/config/application.rb +8 -3
  81. data/spec/rails_app/config/boot.rb +1 -1
  82. data/spec/rails_app/config/environment.rb +1 -1
  83. data/spec/rails_app/config/routes.rb +14 -0
  84. data/spec/rails_app/config/secrets.yml +4 -0
  85. data/spec/rails_app/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +2 -2
  86. data/spec/rails_app/db/migrate/invalidate_active_sessions/20180221093235_add_invalidate_active_sessions_before_to_users.rb +9 -0
  87. data/spec/rails_app/db/migrate/magic_login/20170924151831_add_magic_login_to_users.rb +17 -0
  88. data/spec/rails_app/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +2 -0
  89. data/spec/rails_app/db/schema.rb +7 -9
  90. data/spec/shared_examples/user_magic_login_shared_examples.rb +150 -0
  91. data/spec/shared_examples/user_oauth_shared_examples.rb +1 -1
  92. data/spec/shared_examples/user_remember_me_shared_examples.rb +1 -1
  93. data/spec/shared_examples/user_reset_password_shared_examples.rb +37 -5
  94. data/spec/shared_examples/user_shared_examples.rb +104 -43
  95. data/spec/sorcery_crypto_providers_spec.rb +61 -1
  96. data/spec/sorcery_temporary_token_spec.rb +27 -0
  97. data/spec/spec.opts +1 -1
  98. data/spec/spec_helper.rb +2 -2
  99. data/spec/support/migration_helper.rb +19 -0
  100. data/spec/support/providers/example.rb +11 -0
  101. data/spec/support/providers/example_provider.rb +11 -0
  102. metadata +89 -33
  103. data/gemfiles/active_record-rails40.gemfile +0 -7
  104. data/gemfiles/active_record-rails41.gemfile +0 -7
  105. data/gemfiles/active_record-rails42.gemfile +0 -7
  106. data/spec/rails_app/config/initializers/secret_token.rb +0 -7
@@ -1,6 +1,6 @@
1
1
  Description:
2
2
  Generates the necessary files to get you up and running with Sorcery gem
3
-
3
+
4
4
  Examples:
5
5
  rails generate sorcery:install
6
6
 
@@ -7,7 +7,7 @@ module Sorcery
7
7
  include Rails::Generators::Migration
8
8
  include Sorcery::Generators::Helpers
9
9
 
10
- source_root File.expand_path('../templates', __FILE__)
10
+ source_root File.expand_path('templates', __dir__)
11
11
 
12
12
  argument :submodules, optional: true, type: :array, banner: 'submodules'
13
13
 
@@ -21,9 +21,9 @@ module Sorcery
21
21
  desc: "Specify if you want to add submodules to an existing model\n\t\t\t # (will generate migrations files, and add submodules to config file)"
22
22
 
23
23
  def check_deprecated_options
24
- if options[:migrations]
25
- warn('[DEPRECATED] `--migrations` option is deprecated, please use `--only-submodules` instead')
26
- end
24
+ return unless options[:migrations]
25
+
26
+ warn('[DEPRECATED] `--migrations` option is deprecated, please use `--only-submodules` instead')
27
27
  end
28
28
 
29
29
  # Copy the initializer file to config/initializers folder.
@@ -33,23 +33,22 @@ module Sorcery
33
33
 
34
34
  def configure_initializer_file
35
35
  # Add submodules to the initializer file.
36
- if submodules
37
- submodule_names = submodules.collect { |submodule| ':' + submodule }
36
+ return unless submodules
38
37
 
39
- gsub_file sorcery_config_path, /submodules = \[.*\]/ do |str|
40
- current_submodule_names = (str =~ /\[(.*)\]/ ? Regexp.last_match(1) : '').delete(' ').split(',')
41
- "submodules = [#{(current_submodule_names | submodule_names).join(', ')}]"
42
- end
38
+ submodule_names = submodules.collect { |submodule| ':' + submodule }
39
+
40
+ gsub_file sorcery_config_path, /submodules = \[.*\]/ do |str|
41
+ current_submodule_names = (str =~ /\[(.*)\]/ ? Regexp.last_match(1) : '').delete(' ').split(',')
42
+ "submodules = [#{(current_submodule_names | submodule_names).join(', ')}]"
43
43
  end
44
44
  end
45
45
 
46
46
  def configure_model
47
47
  # Generate the model and add 'authenticates_with_sorcery!' unless you passed --only-submodules
48
- unless only_submodules?
49
- generate "model #{model_class_name} --skip-migration"
48
+ return if only_submodules?
50
49
 
51
- inject_sorcery_to_model
52
- end
50
+ generate "model #{model_class_name} --skip-migration"
51
+ inject_sorcery_to_model
53
52
  end
54
53
 
55
54
  def inject_sorcery_to_model
@@ -61,14 +60,15 @@ module Sorcery
61
60
  # Copy the migrations files to db/migrate folder
62
61
  def copy_migration_files
63
62
  # Copy core migration file in all cases except when you pass --only-submodules.
64
- return unless defined?(Sorcery::Generators::InstallGenerator::ActiveRecord)
63
+ return unless defined?(ActiveRecord)
64
+
65
65
  migration_template 'migration/core.rb', 'db/migrate/sorcery_core.rb', migration_class_name: migration_class_name unless only_submodules?
66
66
 
67
- if submodules
68
- submodules.each do |submodule|
69
- unless submodule == 'http_basic_auth' || submodule == 'session_timeout' || submodule == 'core'
70
- migration_template "migration/#{submodule}.rb", "db/migrate/sorcery_#{submodule}.rb", migration_class_name: migration_class_name
71
- end
67
+ return unless submodules
68
+
69
+ submodules.each do |submodule|
70
+ unless %w[http_basic_auth session_timeout core].include?(submodule)
71
+ migration_template "migration/#{submodule}.rb", "db/migrate/sorcery_#{submodule}.rb", migration_class_name: migration_class_name
72
72
  end
73
73
  end
74
74
  end
@@ -79,7 +79,7 @@ module Sorcery
79
79
  sleep 1 # make sure each time we get a different timestamp
80
80
  Time.new.utc.strftime('%Y%m%d%H%M%S')
81
81
  else
82
- '%.3d' % (current_migration_number(dirname) + 1)
82
+ format('%.3d', (current_migration_number(dirname) + 1))
83
83
  end
84
84
  end
85
85
 
@@ -1,7 +1,9 @@
1
1
  # The first thing you need to configure is which modules you need in your app.
2
2
  # The default is nothing which will include only core features (password encryption, login/logout).
3
+ #
3
4
  # Available submodules are: :user_activation, :http_basic_auth, :remember_me,
4
- # :reset_password, :session_timeout, :brute_force_protection, :activity_logging, :external
5
+ # :reset_password, :session_timeout, :brute_force_protection, :activity_logging,
6
+ # :magic_login, :external
5
7
  Rails.application.config.sorcery.submodules = []
6
8
 
7
9
  # Here you can configure each submodule's features.
@@ -13,8 +15,8 @@ Rails.application.config.sorcery.configure do |config|
13
15
  #
14
16
  # config.not_authenticated_action =
15
17
 
16
- # When a non logged in user tries to enter a page that requires login, save
17
- # the URL he wanted to reach, and send him there after login, using 'redirect_back_or_to'.
18
+ # When a non logged-in user tries to enter a page that requires login, save
19
+ # the URL he wants to reach, and send him there after login, using 'redirect_back_or_to'.
18
20
  # Default: `true`
19
21
  #
20
22
  # config.save_return_to_url =
@@ -29,6 +31,12 @@ Rails.application.config.sorcery.configure do |config|
29
31
  #
30
32
  # config.remember_me_httponly =
31
33
 
34
+ # Set token randomness. (e.g. user activation tokens)
35
+ # The length of the result string is about 4/3 of `token_randomness`.
36
+ # Default: `15`
37
+ #
38
+ # config.token_randomness =
39
+
32
40
  # -- session timeout --
33
41
  # How long in seconds to keep the session alive.
34
42
  # Default: `3600`
@@ -40,6 +48,11 @@ Rails.application.config.sorcery.configure do |config|
40
48
  #
41
49
  # config.session_timeout_from_last_action =
42
50
 
51
+ # Invalidate active sessions. Requires an `invalidate_sessions_before` timestamp column
52
+ # Default: `false`
53
+ #
54
+ # config.session_timeout_invalidate_active_sessions_enabled =
55
+
43
56
  # -- http_basic_auth --
44
57
  # What realm to display for which controller name. For example {"My App" => "Application"}
45
58
  # Default: `{"application" => "Application"}`
@@ -47,23 +60,24 @@ Rails.application.config.sorcery.configure do |config|
47
60
  # config.controller_to_realm_map =
48
61
 
49
62
  # -- activity logging --
50
- # will register the time of last user login, every login.
63
+ # Will register the time of last user login, every login.
51
64
  # Default: `true`
52
65
  #
53
66
  # config.register_login_time =
54
67
 
55
- # will register the time of last user logout, every logout.
68
+ # Will register the time of last user logout, every logout.
56
69
  # Default: `true`
57
70
  #
58
71
  # config.register_logout_time =
59
72
 
60
- # will register the time of last user action, every action.
73
+ # Will register the time of last user action, every action.
61
74
  # Default: `true`
62
75
  #
63
76
  # config.register_last_activity_time =
64
77
 
65
78
  # -- external --
66
- # What providers are supported by this app, i.e. [:twitter, :facebook, :github, :linkedin, :xing, :google, :liveid, :salesforce, :slack] .
79
+ # What providers are supported by this app
80
+ # i.e. [:twitter, :facebook, :github, :linkedin, :xing, :google, :liveid, :salesforce, :slack, :line].
67
81
  # Default: `[]`
68
82
  #
69
83
  # config.external_providers =
@@ -74,16 +88,19 @@ Rails.application.config.sorcery.configure do |config|
74
88
  #
75
89
  # config.ca_file =
76
90
 
77
- # For information about LinkedIn API:
78
- # - user info fields go to https://developer.linkedin.com/documents/profile-fields
79
- # - access permissions go to https://developer.linkedin.com/documents/authentication#granting
91
+ # Linkedin requires r_emailaddress scope to fetch user's email address.
92
+ # You can skip including the email field if you use an intermediary signup form. (using build_from method).
93
+ # The r_emailaddress scope is only necessary if you are using the create_from method directly.
80
94
  #
81
95
  # config.linkedin.key = ""
82
96
  # config.linkedin.secret = ""
83
97
  # config.linkedin.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=linkedin"
84
- # config.linkedin.user_info_fields = ['first-name', 'last-name']
85
- # config.linkedin.user_info_mapping = {first_name: "firstName", last_name: "lastName"}
86
- # config.linkedin.access_permissions = ['r_basicprofile']
98
+ # config.linkedin.user_info_mapping = {
99
+ # first_name: 'localizedFirstName',
100
+ # last_name: 'localizedLastName',
101
+ # email: 'emailAddress'
102
+ # }
103
+ # config.linkedin.scope = "r_liteprofile r_emailaddress"
87
104
  #
88
105
  #
89
106
  # For information about XING API:
@@ -96,7 +113,7 @@ Rails.application.config.sorcery.configure do |config|
96
113
  #
97
114
  #
98
115
  # Twitter will not accept any requests nor redirect uri containing localhost,
99
- # make sure you use 0.0.0.0:3000 to access your app in development
116
+ # Make sure you use 0.0.0.0:3000 to access your app in development
100
117
  #
101
118
  # config.twitter.key = ""
102
119
  # config.twitter.secret = ""
@@ -106,12 +123,19 @@ Rails.application.config.sorcery.configure do |config|
106
123
  # config.facebook.key = ""
107
124
  # config.facebook.secret = ""
108
125
  # config.facebook.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=facebook"
109
- # config.facebook.user_info_mapping = {:email => "name"}
110
- # config.facebook.access_permissions = ["email", "publish_actions"]
126
+ # config.facebook.user_info_path = "me?fields=email"
127
+ # config.facebook.user_info_mapping = {:email => "email"}
128
+ # config.facebook.access_permissions = ["email"]
111
129
  # config.facebook.display = "page"
112
130
  # config.facebook.api_version = "v2.3"
113
131
  # config.facebook.parse = :json
114
132
  #
133
+ # config.instagram.key = ""
134
+ # config.instagram.secret = ""
135
+ # config.instagram.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=instagram"
136
+ # config.instagram.user_info_mapping = {:email => "username"}
137
+ # config.instagram.access_permissions = ["basic", "public_content", "follower_list", "comments", "relationships", "likes"]
138
+ #
115
139
  # config.github.key = ""
116
140
  # config.github.secret = ""
117
141
  # config.github.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=github"
@@ -127,6 +151,13 @@ Rails.application.config.sorcery.configure do |config|
127
151
  # config.wechat.secret = ""
128
152
  # config.wechat.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=wechat"
129
153
  #
154
+ # For Auth0, site is required and should match the domain provided by Auth0.
155
+ #
156
+ # config.auth0.key = ""
157
+ # config.auth0.secret = ""
158
+ # config.auth0.callback_url = "https://0.0.0.0:3000/oauth/callback?provider=auth0"
159
+ # config.auth0.site = "https://example.auth0.com"
160
+ #
130
161
  # config.google.key = ""
131
162
  # config.google.secret = ""
132
163
  # config.google.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=google"
@@ -134,7 +165,8 @@ Rails.application.config.sorcery.configure do |config|
134
165
  # config.google.scope = "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
135
166
  #
136
167
  # For Microsoft Graph, the key will be your App ID, and the secret will be your app password/public key.
137
- # The callback URL "can't contain a query string or invalid special characters", see: https://docs.microsoft.com/en-us/azure/active-directory/active-directory-v2-limitations#restrictions-on-redirect-uris
168
+ # The callback URL "can't contain a query string or invalid special characters"
169
+ # See: https://docs.microsoft.com/en-us/azure/active-directory/active-directory-v2-limitations#restrictions-on-redirect-uris
138
170
  # More information at https://graph.microsoft.io/en-us/docs
139
171
  #
140
172
  # config.microsoft.key = ""
@@ -147,6 +179,7 @@ Rails.application.config.sorcery.configure do |config|
147
179
  # config.vk.secret = ""
148
180
  # config.vk.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=vk"
149
181
  # config.vk.user_info_mapping = {:login => "domain", :name => "full_name"}
182
+ # config.vk.api_version = "5.71"
150
183
  #
151
184
  # config.slack.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=slack"
152
185
  # config.slack.key = ''
@@ -164,7 +197,7 @@ Rails.application.config.sorcery.configure do |config|
164
197
 
165
198
  # For information about JIRA API:
166
199
  # https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+OAuth+authentication
167
- # to obtain the consumer key and the public key you can use the jira-ruby gem https://github.com/sumoheavy/jira-ruby
200
+ # To obtain the consumer key and the public key you can use the jira-ruby gem https://github.com/sumoheavy/jira-ruby
168
201
  # or run openssl req -x509 -nodes -newkey rsa:1024 -sha1 -keyout rsakey.pem -out rsacert.pem to obtain the public key
169
202
  # Make sure you have configured the application link properly
170
203
 
@@ -177,7 +210,7 @@ Rails.application.config.sorcery.configure do |config|
177
210
  # For information about Salesforce API:
178
211
  # https://developer.salesforce.com/signup &
179
212
  # https://www.salesforce.com/us/developer/docs/api_rest/
180
- # Salesforce callback_url must be https. You can run the following to generate self-signed ssl cert
213
+ # Salesforce callback_url must be https. You can run the following to generate self-signed ssl cert:
181
214
  # openssl req -new -newkey rsa:2048 -sha1 -days 365 -nodes -x509 -keyout server.key -out server.crt
182
215
  # Make sure you have configured the application link properly
183
216
  # config.salesforce.key = '123123'
@@ -186,179 +219,240 @@ Rails.application.config.sorcery.configure do |config|
186
219
  # config.salesforce.scope = "full"
187
220
  # config.salesforce.user_info_mapping = {:email => "email"}
188
221
 
222
+ # config.line.key = ""
223
+ # config.line.secret = ""
224
+ # config.line.callback_url = "http://mydomain.com:3000/oauth/callback?provider=line"
225
+
226
+ # For infromation about Discord API
227
+ # https://discordapp.com/developers/docs/topics/oauth2
228
+ # config.discord.key = "xxxxxx"
229
+ # config.discord.secret = "xxxxxx"
230
+ # config.discord.callback_url = "http://localhost:3000/oauth/callback?provider=discord"
231
+ # config.discord.scope = "email guilds"
189
232
  # --- user config ---
190
233
  config.user_config do |user|
191
234
  # -- core --
192
- # specify username attributes, for example: [:username, :email].
235
+ # Specify username attributes, for example: [:username, :email].
193
236
  # Default: `[:email]`
194
237
  #
195
238
  # user.username_attribute_names =
196
239
 
197
- # change *virtual* password attribute, the one which is used until an encrypted one is generated.
240
+ # Change *virtual* password attribute, the one which is used until an encrypted one is generated.
198
241
  # Default: `:password`
199
242
  #
200
243
  # user.password_attribute_name =
201
244
 
202
- # downcase the username before trying to authenticate, default is false
245
+ # Downcase the username before trying to authenticate, default is false
203
246
  # Default: `false`
204
247
  #
205
248
  # user.downcase_username_before_authenticating =
206
249
 
207
- # change default email attribute.
250
+ # Change default email attribute.
208
251
  # Default: `:email`
209
252
  #
210
253
  # user.email_attribute_name =
211
254
 
212
- # change default crypted_password attribute.
255
+ # Change default crypted_password attribute.
213
256
  # Default: `:crypted_password`
214
257
  #
215
258
  # user.crypted_password_attribute_name =
216
259
 
217
- # what pattern to use to join the password with the salt
260
+ # What pattern to use to join the password with the salt
218
261
  # Default: `""`
219
262
  #
220
263
  # user.salt_join_token =
221
264
 
222
- # change default salt attribute.
265
+ # Change default salt attribute.
223
266
  # Default: `:salt`
224
267
  #
225
268
  # user.salt_attribute_name =
226
269
 
227
- # how many times to apply encryption to the password.
228
- # Default: `nil`
270
+ # How many times to apply encryption to the password.
271
+ # Default: 1 in test env, `nil` otherwise
229
272
  #
230
- # user.stretches =
273
+ user.stretches = 1 if Rails.env.test?
231
274
 
232
- # encryption key used to encrypt reversible encryptions such as AES256.
275
+ # Encryption key used to encrypt reversible encryptions such as AES256.
233
276
  # WARNING: If used for users' passwords, changing this key will leave passwords undecryptable!
234
277
  # Default: `nil`
235
278
  #
236
279
  # user.encryption_key =
237
280
 
238
- # use an external encryption class.
281
+ # Use an external encryption class.
239
282
  # Default: `nil`
240
283
  #
241
284
  # user.custom_encryption_provider =
242
285
 
243
- # encryption algorithm name. See 'encryption_algorithm=' for available options.
286
+ # Encryption algorithm name. See 'encryption_algorithm=' for available options.
244
287
  # Default: `:bcrypt`
245
288
  #
246
289
  # user.encryption_algorithm =
247
290
 
248
- # make this configuration inheritable for subclasses. Useful for ActiveRecord's STI.
291
+ # Make this configuration inheritable for subclasses. Useful for ActiveRecord's STI.
249
292
  # Default: `false`
250
293
  #
251
294
  # user.subclasses_inherit_config =
252
295
 
253
296
  # -- remember_me --
254
297
  # How long in seconds the session length will be
255
- # Default: `604800`
298
+ # Default: `60 * 60 * 24 * 7`
256
299
  #
257
300
  # user.remember_me_for =
258
301
 
259
- # when true sorcery will persist a single remember me token for all
260
- # logins/logouts (supporting remembering on multiple browsers simultaneously).
302
+ # When true, sorcery will persist a single remember me token for all
303
+ # logins/logouts (to support remembering on multiple browsers simultaneously).
261
304
  # Default: false
262
305
  #
263
306
  # user.remember_me_token_persist_globally =
264
307
 
265
308
  # -- user_activation --
266
- # the attribute name to hold activation state (active/pending).
309
+ # The attribute name to hold activation state (active/pending).
267
310
  # Default: `:activation_state`
268
311
  #
269
312
  # user.activation_state_attribute_name =
270
313
 
271
- # the attribute name to hold activation code (sent by email).
314
+ # The attribute name to hold activation code (sent by email).
272
315
  # Default: `:activation_token`
273
316
  #
274
317
  # user.activation_token_attribute_name =
275
318
 
276
- # the attribute name to hold activation code expiration date.
319
+ # The attribute name to hold activation code expiration date.
277
320
  # Default: `:activation_token_expires_at`
278
321
  #
279
322
  # user.activation_token_expires_at_attribute_name =
280
323
 
281
- # how many seconds before the activation code expires. nil for never expires.
324
+ # How many seconds before the activation code expires. nil for never expires.
282
325
  # Default: `nil`
283
326
  #
284
327
  # user.activation_token_expiration_period =
285
328
 
286
- # your mailer class. Required.
329
+ # REQUIRED:
330
+ # User activation mailer class.
287
331
  # Default: `nil`
288
332
  #
289
333
  # user.user_activation_mailer =
290
334
 
291
- # when true sorcery will not automatically
292
- # email activation details and allow you to
293
- # manually handle how and when email is sent.
335
+ # When true, sorcery will not automatically
336
+ # send the activation details email, and allow you to
337
+ # manually handle how and when the email is sent.
294
338
  # Default: `false`
295
339
  #
296
340
  # user.activation_mailer_disabled =
297
341
 
298
- # method to send email related
342
+ # Method to send email related
299
343
  # options: `:deliver_later`, `:deliver_now`, `:deliver`
300
344
  # Default: :deliver (Rails version < 4.2) or :deliver_now (Rails version 4.2+)
301
345
  #
302
346
  # user.email_delivery_method =
303
347
 
304
- # activation needed email method on your mailer class.
348
+ # Activation needed email method on your mailer class.
305
349
  # Default: `:activation_needed_email`
306
350
  #
307
351
  # user.activation_needed_email_method_name =
308
352
 
309
- # activation success email method on your mailer class.
353
+ # Activation success email method on your mailer class.
310
354
  # Default: `:activation_success_email`
311
355
  #
312
356
  # user.activation_success_email_method_name =
313
357
 
314
- # do you want to prevent or allow users that did not activate by email to login?
358
+ # Do you want to prevent users who did not activate by email from logging in?
315
359
  # Default: `true`
316
360
  #
317
361
  # user.prevent_non_active_users_to_login =
318
362
 
319
363
  # -- reset_password --
320
- # reset password code attribute name.
364
+ # Password reset token attribute name.
321
365
  # Default: `:reset_password_token`
322
366
  #
323
367
  # user.reset_password_token_attribute_name =
324
368
 
325
- # expires at attribute name.
369
+ # Password token expiry attribute name.
326
370
  # Default: `:reset_password_token_expires_at`
327
371
  #
328
372
  # user.reset_password_token_expires_at_attribute_name =
329
373
 
330
- # when was email sent, used for hammering protection.
374
+ # When was password reset email sent. Used for hammering protection.
331
375
  # Default: `:reset_password_email_sent_at`
332
376
  #
333
377
  # user.reset_password_email_sent_at_attribute_name =
334
378
 
335
- # mailer class. Needed.
379
+ # REQUIRED:
380
+ # Password reset mailer class.
336
381
  # Default: `nil`
337
382
  #
338
383
  # user.reset_password_mailer =
339
384
 
340
- # reset password email method on your mailer class.
385
+ # Reset password email method on your mailer class.
341
386
  # Default: `:reset_password_email`
342
387
  #
343
388
  # user.reset_password_email_method_name =
344
389
 
345
- # when true sorcery will not automatically
346
- # email password reset details and allow you to
347
- # manually handle how and when email is sent
390
+ # When true, sorcery will not automatically
391
+ # send the password reset details email, and allow you to
392
+ # manually handle how and when the email is sent
348
393
  # Default: `false`
349
394
  #
350
395
  # user.reset_password_mailer_disabled =
351
396
 
352
- # how many seconds before the reset request expires. nil for never expires.
397
+ # How many seconds before the reset request expires. nil for never expires.
353
398
  # Default: `nil`
354
399
  #
355
400
  # user.reset_password_expiration_period =
356
401
 
357
- # hammering protection, how long in seconds to wait before allowing another email to be sent.
402
+ # Hammering protection: how long in seconds to wait before allowing another email to be sent.
358
403
  # Default: `5 * 60`
359
404
  #
360
405
  # user.reset_password_time_between_emails =
361
406
 
407
+ # Access counter to a reset password page attribute name
408
+ # Default: `:access_count_to_reset_password_page`
409
+ #
410
+ # user.reset_password_page_access_count_attribute_name =
411
+
412
+ # -- magic_login --
413
+ # Magic login code attribute name.
414
+ # Default: `:magic_login_token`
415
+ #
416
+ # user.magic_login_token_attribute_name =
417
+
418
+ # Magic login expiry attribute name.
419
+ # Default: `:magic_login_token_expires_at`
420
+ #
421
+ # user.magic_login_token_expires_at_attribute_name =
422
+
423
+ # When was magic login email sent — used for hammering protection.
424
+ # Default: `:magic_login_email_sent_at`
425
+ #
426
+ # user.magic_login_email_sent_at_attribute_name =
427
+
428
+ # REQUIRED:
429
+ # Magic login mailer class.
430
+ # Default: `nil`
431
+ #
432
+ # user.magic_login_mailer_class =
433
+
434
+ # Magic login email method on your mailer class.
435
+ # Default: `:magic_login_email`
436
+ #
437
+ # user.magic_login_email_method_name =
438
+
439
+ # When true, sorcery will not automatically
440
+ # send magic login details email, and allow you to
441
+ # manually handle how and when the email is sent
442
+ # Default: `true`
443
+ #
444
+ # user.magic_login_mailer_disabled =
445
+
446
+ # How many seconds before the request expires. nil for never expires.
447
+ # Default: `nil`
448
+ #
449
+ # user.magic_login_expiration_period =
450
+
451
+ # Hammering protection: how long in seconds to wait before allowing another email to be sent.
452
+ # Default: `5 * 60`
453
+ #
454
+ # user.magic_login_time_between_emails =
455
+
362
456
  # -- brute_force_protection --
363
457
  # Failed logins attribute name.
364
458
  # Default: `:failed_logins_count`
@@ -370,12 +464,12 @@ Rails.application.config.sorcery.configure do |config|
370
464
  #
371
465
  # user.lock_expires_at_attribute_name =
372
466
 
373
- # How many failed logins allowed.
467
+ # How many failed logins are allowed.
374
468
  # Default: `50`
375
469
  #
376
470
  # user.consecutive_login_retries_amount_limit =
377
471
 
378
- # How long the user should be banned. in seconds. 0 for permanent.
472
+ # How long the user should be banned, in seconds. 0 for permanent.
379
473
  # Default: `60 * 60`
380
474
  #
381
475
  # user.login_lock_time_period =
@@ -390,16 +484,17 @@ Rails.application.config.sorcery.configure do |config|
390
484
  #
391
485
  # user.unlock_token_email_method_name =
392
486
 
393
- # when true sorcery will not automatically
394
- # send email with unlock token
487
+ # When true, sorcery will not automatically
488
+ # send email with the unlock token
395
489
  # Default: `false`
396
490
  #
397
491
  # user.unlock_token_mailer_disabled = true
398
492
 
399
- # Unlock token mailer class
493
+ # REQUIRED:
494
+ # Unlock token mailer class.
400
495
  # Default: `nil`
401
496
  #
402
- # user.unlock_token_mailer = UserMailer
497
+ # user.unlock_token_mailer =
403
498
 
404
499
  # -- activity logging --
405
500
  # Last login attribute name.
@@ -417,7 +512,7 @@ Rails.application.config.sorcery.configure do |config|
417
512
  #
418
513
  # user.last_activity_at_attribute_name =
419
514
 
420
- # How long since last activity is the user defined logged out?
515
+ # How long since user's last activity will they be considered logged out?
421
516
  # Default: `10 * 60`
422
517
  #
423
518
  # user.activity_timeout =
@@ -428,17 +523,17 @@ Rails.application.config.sorcery.configure do |config|
428
523
  #
429
524
  # user.authentications_class =
430
525
 
431
- # User's identifier in authentications class.
526
+ # User's identifier in the `authentications` class.
432
527
  # Default: `:user_id`
433
528
  #
434
529
  # user.authentications_user_id_attribute_name =
435
530
 
436
- # Provider's identifier in authentications class.
531
+ # Provider's identifier in the `authentications` class.
437
532
  # Default: `:provider`
438
533
  #
439
534
  # user.provider_attribute_name =
440
535
 
441
- # User's external unique identifier in authentications class.
536
+ # User's external unique identifier in the `authentications` class.
442
537
  # Default: `:uid`
443
538
  #
444
539
  # user.provider_uid_attribute_name =
@@ -446,5 +541,5 @@ Rails.application.config.sorcery.configure do |config|
446
541
 
447
542
  # This line must come after the 'user config' block.
448
543
  # Define which model authenticates with sorcery.
449
- config.user_class = '<%= model_class_name %>'
544
+ config.user_class = "<%= model_class_name %>"
450
545
  end