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.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +20 -0
- data/.rubocop.yml +55 -0
- data/.rubocop_todo.yml +145 -0
- data/.travis.yml +3 -52
- data/CHANGELOG.md +69 -0
- data/Gemfile +3 -3
- data/{LICENSE.txt → LICENSE.md} +1 -1
- data/README.md +34 -7
- data/lib/generators/sorcery/USAGE +1 -1
- data/lib/generators/sorcery/install_generator.rb +21 -21
- data/lib/generators/sorcery/templates/initializer.rb +164 -69
- data/lib/generators/sorcery/templates/migration/activity_logging.rb +4 -4
- data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +3 -3
- data/lib/generators/sorcery/templates/migration/core.rb +2 -2
- data/lib/generators/sorcery/templates/migration/external.rb +3 -3
- data/lib/generators/sorcery/templates/migration/magic_login.rb +9 -0
- data/lib/generators/sorcery/templates/migration/remember_me.rb +2 -2
- data/lib/generators/sorcery/templates/migration/reset_password.rb +4 -3
- data/lib/generators/sorcery/templates/migration/user_activation.rb +3 -3
- data/lib/sorcery.rb +2 -0
- data/lib/sorcery/adapters/active_record_adapter.rb +3 -2
- data/lib/sorcery/adapters/mongoid_adapter.rb +23 -11
- data/lib/sorcery/controller.rb +26 -15
- data/lib/sorcery/controller/config.rb +2 -0
- data/lib/sorcery/controller/submodules/activity_logging.rb +14 -3
- data/lib/sorcery/controller/submodules/brute_force_protection.rb +7 -3
- data/lib/sorcery/controller/submodules/external.rb +48 -33
- data/lib/sorcery/controller/submodules/http_basic_auth.rb +5 -1
- data/lib/sorcery/controller/submodules/remember_me.rb +9 -10
- data/lib/sorcery/controller/submodules/session_timeout.rb +32 -6
- data/lib/sorcery/crypto_providers/aes256.rb +2 -1
- data/lib/sorcery/crypto_providers/bcrypt.rb +8 -2
- data/lib/sorcery/engine.rb +16 -3
- data/lib/sorcery/model.rb +14 -10
- data/lib/sorcery/model/config.rb +12 -4
- data/lib/sorcery/model/submodules/brute_force_protection.rb +6 -7
- data/lib/sorcery/model/submodules/external.rb +19 -3
- data/lib/sorcery/model/submodules/magic_login.rb +130 -0
- data/lib/sorcery/model/submodules/reset_password.rb +25 -2
- data/lib/sorcery/model/submodules/user_activation.rb +1 -1
- data/lib/sorcery/model/temporary_token.rb +3 -1
- data/lib/sorcery/protocols/oauth.rb +1 -0
- data/lib/sorcery/providers/auth0.rb +46 -0
- data/lib/sorcery/providers/discord.rb +52 -0
- data/lib/sorcery/providers/heroku.rb +1 -0
- data/lib/sorcery/providers/instagram.rb +73 -0
- data/lib/sorcery/providers/line.rb +47 -0
- data/lib/sorcery/providers/linkedin.rb +45 -36
- data/lib/sorcery/providers/vk.rb +5 -4
- data/lib/sorcery/providers/wechat.rb +8 -6
- data/lib/sorcery/test_helpers/internal.rb +5 -4
- data/lib/sorcery/test_helpers/internal/rails.rb +11 -11
- data/lib/sorcery/test_helpers/rails/request.rb +20 -0
- data/lib/sorcery/version.rb +1 -1
- data/sorcery.gemspec +28 -11
- data/spec/active_record/user_activation_spec.rb +2 -2
- data/spec/active_record/user_activity_logging_spec.rb +2 -2
- data/spec/active_record/user_brute_force_protection_spec.rb +2 -2
- data/spec/active_record/user_magic_login_spec.rb +15 -0
- data/spec/active_record/user_oauth_spec.rb +2 -2
- data/spec/active_record/user_remember_me_spec.rb +2 -2
- data/spec/active_record/user_reset_password_spec.rb +2 -2
- data/spec/active_record/user_spec.rb +0 -10
- data/spec/controllers/controller_http_basic_auth_spec.rb +1 -1
- data/spec/controllers/controller_oauth2_spec.rb +212 -123
- data/spec/controllers/controller_oauth_spec.rb +7 -7
- data/spec/controllers/controller_remember_me_spec.rb +16 -8
- data/spec/controllers/controller_session_timeout_spec.rb +90 -3
- data/spec/controllers/controller_spec.rb +13 -3
- data/spec/orm/active_record.rb +2 -2
- data/spec/providers/example_provider_spec.rb +17 -0
- data/spec/providers/example_spec.rb +17 -0
- data/spec/providers/vk_spec.rb +42 -0
- data/spec/rails_app/app/assets/config/manifest.js +1 -0
- data/spec/rails_app/app/controllers/sorcery_controller.rb +131 -32
- data/spec/rails_app/app/mailers/sorcery_mailer.rb +7 -0
- data/spec/rails_app/app/views/sorcery_mailer/magic_login_email.html.erb +13 -0
- data/spec/rails_app/app/views/sorcery_mailer/magic_login_email.text.erb +6 -0
- data/spec/rails_app/config/application.rb +8 -3
- data/spec/rails_app/config/boot.rb +1 -1
- data/spec/rails_app/config/environment.rb +1 -1
- data/spec/rails_app/config/routes.rb +14 -0
- data/spec/rails_app/config/secrets.yml +4 -0
- data/spec/rails_app/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +2 -2
- data/spec/rails_app/db/migrate/invalidate_active_sessions/20180221093235_add_invalidate_active_sessions_before_to_users.rb +9 -0
- data/spec/rails_app/db/migrate/magic_login/20170924151831_add_magic_login_to_users.rb +17 -0
- data/spec/rails_app/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +2 -0
- data/spec/rails_app/db/schema.rb +7 -9
- data/spec/shared_examples/user_magic_login_shared_examples.rb +150 -0
- data/spec/shared_examples/user_oauth_shared_examples.rb +1 -1
- data/spec/shared_examples/user_remember_me_shared_examples.rb +1 -1
- data/spec/shared_examples/user_reset_password_shared_examples.rb +37 -5
- data/spec/shared_examples/user_shared_examples.rb +104 -43
- data/spec/sorcery_crypto_providers_spec.rb +61 -1
- data/spec/sorcery_temporary_token_spec.rb +27 -0
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/support/migration_helper.rb +19 -0
- data/spec/support/providers/example.rb +11 -0
- data/spec/support/providers/example_provider.rb +11 -0
- metadata +89 -33
- data/gemfiles/active_record-rails40.gemfile +0 -7
- data/gemfiles/active_record-rails41.gemfile +0 -7
- data/gemfiles/active_record-rails42.gemfile +0 -7
- data/spec/rails_app/config/initializers/secret_token.rb +0 -7
@@ -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('
|
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
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
37
|
-
submodule_names = submodules.collect { |submodule| ':' + submodule }
|
36
|
+
return unless submodules
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
49
|
-
generate "model #{model_class_name} --skip-migration"
|
48
|
+
return if only_submodules?
|
50
49
|
|
51
|
-
|
52
|
-
|
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?(
|
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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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'
|
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,
|
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
|
17
|
-
# the URL he
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
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
|
-
#
|
78
|
-
#
|
79
|
-
#
|
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.
|
85
|
-
#
|
86
|
-
#
|
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
|
-
#
|
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.
|
110
|
-
# config.facebook.
|
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"
|
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
|
-
#
|
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
|
-
#
|
235
|
+
# Specify username attributes, for example: [:username, :email].
|
193
236
|
# Default: `[:email]`
|
194
237
|
#
|
195
238
|
# user.username_attribute_names =
|
196
239
|
|
197
|
-
#
|
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
|
-
#
|
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
|
-
#
|
250
|
+
# Change default email attribute.
|
208
251
|
# Default: `:email`
|
209
252
|
#
|
210
253
|
# user.email_attribute_name =
|
211
254
|
|
212
|
-
#
|
255
|
+
# Change default crypted_password attribute.
|
213
256
|
# Default: `:crypted_password`
|
214
257
|
#
|
215
258
|
# user.crypted_password_attribute_name =
|
216
259
|
|
217
|
-
#
|
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
|
-
#
|
265
|
+
# Change default salt attribute.
|
223
266
|
# Default: `:salt`
|
224
267
|
#
|
225
268
|
# user.salt_attribute_name =
|
226
269
|
|
227
|
-
#
|
228
|
-
# Default: `nil`
|
270
|
+
# How many times to apply encryption to the password.
|
271
|
+
# Default: 1 in test env, `nil` otherwise
|
229
272
|
#
|
230
|
-
|
273
|
+
user.stretches = 1 if Rails.env.test?
|
231
274
|
|
232
|
-
#
|
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
|
-
#
|
281
|
+
# Use an external encryption class.
|
239
282
|
# Default: `nil`
|
240
283
|
#
|
241
284
|
# user.custom_encryption_provider =
|
242
285
|
|
243
|
-
#
|
286
|
+
# Encryption algorithm name. See 'encryption_algorithm=' for available options.
|
244
287
|
# Default: `:bcrypt`
|
245
288
|
#
|
246
289
|
# user.encryption_algorithm =
|
247
290
|
|
248
|
-
#
|
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: `
|
298
|
+
# Default: `60 * 60 * 24 * 7`
|
256
299
|
#
|
257
300
|
# user.remember_me_for =
|
258
301
|
|
259
|
-
#
|
260
|
-
# logins/logouts (
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
329
|
+
# REQUIRED:
|
330
|
+
# User activation mailer class.
|
287
331
|
# Default: `nil`
|
288
332
|
#
|
289
333
|
# user.user_activation_mailer =
|
290
334
|
|
291
|
-
#
|
292
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
379
|
+
# REQUIRED:
|
380
|
+
# Password reset mailer class.
|
336
381
|
# Default: `nil`
|
337
382
|
#
|
338
383
|
# user.reset_password_mailer =
|
339
384
|
|
340
|
-
#
|
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
|
-
#
|
346
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
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
|
-
#
|
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
|
-
#
|
493
|
+
# REQUIRED:
|
494
|
+
# Unlock token mailer class.
|
400
495
|
# Default: `nil`
|
401
496
|
#
|
402
|
-
# user.unlock_token_mailer =
|
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
|
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 =
|
544
|
+
config.user_class = "<%= model_class_name %>"
|
450
545
|
end
|