sorcery 0.16.1 → 0.18.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -1
- data/README.md +9 -8
- data/lib/generators/sorcery/helpers.rb +1 -1
- data/lib/generators/sorcery/install_generator.rb +9 -11
- data/lib/generators/sorcery/templates/initializer.rb +34 -10
- data/lib/generators/sorcery/templates/migration/core.rb +1 -3
- data/lib/sorcery/adapters/active_record_adapter.rb +12 -14
- data/lib/sorcery/adapters/mongoid_adapter.rb +7 -9
- data/lib/sorcery/controller/config.rb +27 -29
- data/lib/sorcery/controller/submodules/activity_logging.rb +4 -7
- data/lib/sorcery/controller/submodules/brute_force_protection.rb +4 -1
- data/lib/sorcery/controller/submodules/external.rb +12 -12
- data/lib/sorcery/controller/submodules/http_basic_auth.rb +7 -2
- data/lib/sorcery/controller/submodules/remember_me.rb +2 -1
- data/lib/sorcery/controller/submodules/session_timeout.rb +2 -2
- data/lib/sorcery/controller.rb +37 -19
- data/lib/sorcery/crypto_providers/aes256.rb +4 -2
- data/lib/sorcery/crypto_providers/bcrypt.rb +2 -1
- data/lib/sorcery/crypto_providers/md5.rb +1 -0
- data/lib/sorcery/crypto_providers/sha1.rb +1 -0
- data/lib/sorcery/crypto_providers/sha256.rb +1 -0
- data/lib/sorcery/crypto_providers/sha512.rb +1 -0
- data/lib/sorcery/engine.rb +6 -4
- data/lib/sorcery/errors.rb +10 -0
- data/lib/sorcery/model/config.rb +20 -31
- data/lib/sorcery/model/submodules/activity_logging.rb +8 -6
- data/lib/sorcery/model/submodules/brute_force_protection.rb +16 -14
- data/lib/sorcery/model/submodules/external.rb +8 -10
- data/lib/sorcery/model/submodules/magic_login.rb +8 -4
- data/lib/sorcery/model/submodules/remember_me.rb +3 -3
- data/lib/sorcery/model/submodules/reset_password.rb +23 -13
- data/lib/sorcery/model/submodules/user_activation.rb +19 -17
- data/lib/sorcery/model/temporary_token.rb +5 -5
- data/lib/sorcery/model.rb +29 -28
- data/lib/sorcery/protocols/oauth2.rb +1 -0
- data/lib/sorcery/providers/base.rb +1 -1
- data/lib/sorcery/providers/facebook.rb +2 -2
- data/lib/sorcery/providers/github.rb +3 -3
- data/lib/sorcery/providers/heroku.rb +1 -2
- data/lib/sorcery/providers/jira.rb +3 -2
- data/lib/sorcery/providers/line.rb +2 -4
- data/lib/sorcery/providers/microsoft.rb +1 -1
- data/lib/sorcery/providers/slack.rb +1 -1
- data/lib/sorcery/providers/twitter.rb +2 -2
- data/lib/sorcery/providers/vk.rb +4 -4
- data/lib/sorcery/providers/xing.rb +3 -2
- data/lib/sorcery/test_helpers/internal/rails.rb +5 -22
- data/lib/sorcery/test_helpers/internal.rb +4 -6
- data/lib/sorcery/test_helpers/rails/integration.rb +1 -1
- data/lib/sorcery/test_helpers/rails/request.rb +1 -1
- data/lib/sorcery/version.rb +1 -1
- data/lib/sorcery.rb +6 -1
- metadata +23 -157
- data/.document +0 -5
- data/.github/FUNDING.yml +0 -1
- data/.github/ISSUE_TEMPLATE.md +0 -20
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -5
- data/.github/workflows/ruby.yml +0 -49
- data/.gitignore +0 -59
- data/.rspec +0 -1
- data/.rubocop.yml +0 -55
- data/.rubocop_todo.yml +0 -163
- data/CODE_OF_CONDUCT.md +0 -14
- data/Gemfile +0 -8
- data/Rakefile +0 -8
- data/SECURITY.md +0 -19
- data/gemfiles/rails_52.gemfile +0 -7
- data/gemfiles/rails_60.gemfile +0 -7
- data/sorcery.gemspec +0 -49
- data/spec/active_record/user_activation_spec.rb +0 -17
- data/spec/active_record/user_activity_logging_spec.rb +0 -15
- data/spec/active_record/user_brute_force_protection_spec.rb +0 -15
- data/spec/active_record/user_magic_login_spec.rb +0 -15
- data/spec/active_record/user_oauth_spec.rb +0 -15
- data/spec/active_record/user_remember_me_spec.rb +0 -15
- data/spec/active_record/user_reset_password_spec.rb +0 -15
- data/spec/active_record/user_spec.rb +0 -27
- data/spec/controllers/controller_activity_logging_spec.rb +0 -113
- data/spec/controllers/controller_brute_force_protection_spec.rb +0 -41
- data/spec/controllers/controller_http_basic_auth_spec.rb +0 -67
- data/spec/controllers/controller_oauth2_spec.rb +0 -568
- data/spec/controllers/controller_oauth_spec.rb +0 -266
- data/spec/controllers/controller_remember_me_spec.rb +0 -130
- data/spec/controllers/controller_session_timeout_spec.rb +0 -166
- data/spec/controllers/controller_spec.rb +0 -194
- data/spec/orm/active_record.rb +0 -21
- data/spec/providers/example_provider_spec.rb +0 -17
- data/spec/providers/example_spec.rb +0 -17
- data/spec/providers/vk_spec.rb +0 -42
- data/spec/rails_app/app/active_record/authentication.rb +0 -3
- data/spec/rails_app/app/active_record/user.rb +0 -5
- data/spec/rails_app/app/active_record/user_provider.rb +0 -3
- data/spec/rails_app/app/assets/config/manifest.js +0 -1
- data/spec/rails_app/app/controllers/application_controller.rb +0 -2
- data/spec/rails_app/app/controllers/sorcery_controller.rb +0 -489
- data/spec/rails_app/app/helpers/application_helper.rb +0 -2
- data/spec/rails_app/app/mailers/sorcery_mailer.rb +0 -38
- data/spec/rails_app/app/views/application/index.html.erb +0 -17
- data/spec/rails_app/app/views/layouts/application.html.erb +0 -14
- data/spec/rails_app/app/views/sorcery_mailer/activation_email.html.erb +0 -17
- data/spec/rails_app/app/views/sorcery_mailer/activation_email.text.erb +0 -9
- data/spec/rails_app/app/views/sorcery_mailer/activation_needed_email.html.erb +0 -17
- data/spec/rails_app/app/views/sorcery_mailer/activation_success_email.html.erb +0 -17
- data/spec/rails_app/app/views/sorcery_mailer/activation_success_email.text.erb +0 -9
- data/spec/rails_app/app/views/sorcery_mailer/magic_login_email.html.erb +0 -13
- data/spec/rails_app/app/views/sorcery_mailer/magic_login_email.text.erb +0 -6
- data/spec/rails_app/app/views/sorcery_mailer/reset_password_email.html.erb +0 -16
- data/spec/rails_app/app/views/sorcery_mailer/reset_password_email.text.erb +0 -8
- data/spec/rails_app/app/views/sorcery_mailer/send_unlock_token_email.text.erb +0 -1
- data/spec/rails_app/config/application.rb +0 -61
- data/spec/rails_app/config/boot.rb +0 -4
- data/spec/rails_app/config/database.yml +0 -22
- data/spec/rails_app/config/environment.rb +0 -5
- data/spec/rails_app/config/environments/test.rb +0 -37
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails_app/config/initializers/compatible_legacy_migration.rb +0 -11
- data/spec/rails_app/config/initializers/inflections.rb +0 -10
- data/spec/rails_app/config/initializers/mime_types.rb +0 -5
- data/spec/rails_app/config/initializers/session_store.rb +0 -12
- data/spec/rails_app/config/locales/en.yml +0 -5
- data/spec/rails_app/config/routes.rb +0 -81
- data/spec/rails_app/config/secrets.yml +0 -4
- data/spec/rails_app/config.ru +0 -4
- data/spec/rails_app/db/migrate/activation/20101224223622_add_activation_to_users.rb +0 -17
- data/spec/rails_app/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -19
- data/spec/rails_app/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -13
- data/spec/rails_app/db/migrate/core/20101224223620_create_users.rb +0 -16
- data/spec/rails_app/db/migrate/external/20101224223628_create_authentications_and_user_providers.rb +0 -22
- data/spec/rails_app/db/migrate/invalidate_active_sessions/20180221093235_add_invalidate_active_sessions_before_to_users.rb +0 -9
- data/spec/rails_app/db/migrate/magic_login/20170924151831_add_magic_login_to_users.rb +0 -17
- data/spec/rails_app/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -15
- data/spec/rails_app/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -15
- data/spec/rails_app/db/schema.rb +0 -21
- data/spec/rails_app/db/seeds.rb +0 -7
- data/spec/shared_examples/user_activation_shared_examples.rb +0 -361
- data/spec/shared_examples/user_activity_logging_shared_examples.rb +0 -106
- data/spec/shared_examples/user_brute_force_protection_shared_examples.rb +0 -151
- data/spec/shared_examples/user_magic_login_shared_examples.rb +0 -150
- data/spec/shared_examples/user_oauth_shared_examples.rb +0 -33
- data/spec/shared_examples/user_remember_me_shared_examples.rb +0 -129
- data/spec/shared_examples/user_reset_password_shared_examples.rb +0 -358
- data/spec/shared_examples/user_shared_examples.rb +0 -678
- data/spec/sorcery_crypto_providers_spec.rb +0 -245
- data/spec/sorcery_temporary_token_spec.rb +0 -27
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -50
- data/spec/support/migration_helper.rb +0 -29
- data/spec/support/providers/example.rb +0 -11
- data/spec/support/providers/example_provider.rb +0 -11
|
@@ -18,18 +18,18 @@ module Sorcery
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
module ClassMethods
|
|
21
|
-
def load_from_token(token, token_attr_name, token_expiration_date_attr = nil, &
|
|
22
|
-
return token_response(failure: :invalid_token, &
|
|
21
|
+
def load_from_token(token, token_attr_name, token_expiration_date_attr = nil, &)
|
|
22
|
+
return token_response(failure: :invalid_token, &) if token.blank?
|
|
23
23
|
|
|
24
24
|
user = sorcery_adapter.find_by_token(token_attr_name, token)
|
|
25
25
|
|
|
26
|
-
return token_response(failure: :user_not_found, &
|
|
26
|
+
return token_response(failure: :user_not_found, &) unless user
|
|
27
27
|
|
|
28
28
|
unless check_expiration_date(user, token_expiration_date_attr)
|
|
29
|
-
return token_response(user: user, failure: :token_expired, &
|
|
29
|
+
return token_response(user: user, failure: :token_expired, &)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
token_response(user: user, return_value: user, &
|
|
32
|
+
token_response(user: user, return_value: user, &)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
protected
|
data/lib/sorcery/model.rb
CHANGED
|
@@ -17,7 +17,7 @@ module Sorcery
|
|
|
17
17
|
include_required_submodules!
|
|
18
18
|
|
|
19
19
|
# This runs the options block set in the initializer on the model class.
|
|
20
|
-
::Sorcery::Controller::Config.user_config.tap { |blk| blk
|
|
20
|
+
::Sorcery::Controller::Config.user_config.tap { |blk| blk&.call(@sorcery_config) }
|
|
21
21
|
|
|
22
22
|
define_base_fields
|
|
23
23
|
init_orm_hooks!
|
|
@@ -48,14 +48,10 @@ module Sorcery
|
|
|
48
48
|
@sorcery_config.submodules = ::Sorcery::Controller::Config.submodules
|
|
49
49
|
@sorcery_config.submodules.each do |mod|
|
|
50
50
|
# TODO: Is there a cleaner way to handle missing submodules?
|
|
51
|
-
# rubocop:disable
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
# don't stop on a missing submodule. Needed because some submodules are only defined
|
|
56
|
-
# in the controller side.
|
|
57
|
-
end
|
|
58
|
-
# rubocop:enable Lint/HandleExceptions
|
|
51
|
+
include Submodules.const_get(mod.to_s.split('_').map(&:capitalize).join) # rubocop:disable Layout/EmptyLinesAfterModuleInclusion
|
|
52
|
+
rescue NameError
|
|
53
|
+
# don't stop on a missing submodule. Needed because some submodules are only defined
|
|
54
|
+
# in the controller side.
|
|
59
55
|
end
|
|
60
56
|
end
|
|
61
57
|
end
|
|
@@ -86,19 +82,13 @@ module Sorcery
|
|
|
86
82
|
def authenticate(*credentials, &block)
|
|
87
83
|
raise ArgumentError, 'at least 2 arguments required' if credentials.size < 2
|
|
88
84
|
|
|
89
|
-
if credentials[0].blank?
|
|
90
|
-
return authentication_response(return_value: false, failure: :invalid_login, &block)
|
|
91
|
-
end
|
|
85
|
+
return authentication_response(return_value: false, failure: :invalid_login, &block) if credentials[0].blank?
|
|
92
86
|
|
|
93
|
-
if @sorcery_config.downcase_username_before_authenticating
|
|
94
|
-
credentials[0].downcase!
|
|
95
|
-
end
|
|
87
|
+
credentials[0].downcase! if @sorcery_config.downcase_username_before_authenticating
|
|
96
88
|
|
|
97
89
|
user = sorcery_adapter.find_by_credentials(credentials)
|
|
98
90
|
|
|
99
|
-
unless user
|
|
100
|
-
return authentication_response(failure: :invalid_login, &block)
|
|
101
|
-
end
|
|
91
|
+
return authentication_response(failure: :invalid_login, &block) unless user
|
|
102
92
|
|
|
103
93
|
set_encryption_attributes
|
|
104
94
|
|
|
@@ -109,9 +99,7 @@ module Sorcery
|
|
|
109
99
|
@sorcery_config.before_authenticate.each do |callback|
|
|
110
100
|
success, reason = user.send(callback)
|
|
111
101
|
|
|
112
|
-
unless success
|
|
113
|
-
return authentication_response(user: user, failure: reason, &block)
|
|
114
|
-
end
|
|
102
|
+
return authentication_response(user: user, failure: reason, &block) unless success
|
|
115
103
|
end
|
|
116
104
|
|
|
117
105
|
unless user.valid_password?(credentials[1])
|
|
@@ -131,6 +119,20 @@ module Sorcery
|
|
|
131
119
|
@sorcery_config.encryption_provider.encrypt(*tokens)
|
|
132
120
|
end
|
|
133
121
|
|
|
122
|
+
# FIXME: This method of passing config to the hashing provider is
|
|
123
|
+
# questionable, and has been refactored in Sorcery v1.
|
|
124
|
+
def set_encryption_attributes
|
|
125
|
+
if @sorcery_config.encryption_provider.respond_to?(:stretches) && @sorcery_config.stretches
|
|
126
|
+
@sorcery_config.encryption_provider.stretches = @sorcery_config.stretches
|
|
127
|
+
end
|
|
128
|
+
if @sorcery_config.encryption_provider.respond_to?(:join_token) && @sorcery_config.salt_join_token
|
|
129
|
+
@sorcery_config.encryption_provider.join_token = @sorcery_config.salt_join_token
|
|
130
|
+
end
|
|
131
|
+
return unless @sorcery_config.encryption_provider.respond_to?(:pepper) && @sorcery_config.pepper
|
|
132
|
+
|
|
133
|
+
@sorcery_config.encryption_provider.pepper = @sorcery_config.pepper
|
|
134
|
+
end
|
|
135
|
+
|
|
134
136
|
protected
|
|
135
137
|
|
|
136
138
|
def authentication_response(options = {})
|
|
@@ -139,12 +141,6 @@ module Sorcery
|
|
|
139
141
|
options[:return_value]
|
|
140
142
|
end
|
|
141
143
|
|
|
142
|
-
def set_encryption_attributes
|
|
143
|
-
@sorcery_config.encryption_provider.stretches = @sorcery_config.stretches if @sorcery_config.encryption_provider.respond_to?(:stretches) && @sorcery_config.stretches
|
|
144
|
-
@sorcery_config.encryption_provider.join_token = @sorcery_config.salt_join_token if @sorcery_config.encryption_provider.respond_to?(:join_token) && @sorcery_config.salt_join_token
|
|
145
|
-
@sorcery_config.encryption_provider.pepper = @sorcery_config.pepper if @sorcery_config.encryption_provider.respond_to?(:pepper) && @sorcery_config.pepper
|
|
146
|
-
end
|
|
147
|
-
|
|
148
144
|
def add_config_inheritance
|
|
149
145
|
class_eval do
|
|
150
146
|
def self.inherited(subclass)
|
|
@@ -177,6 +173,9 @@ module Sorcery
|
|
|
177
173
|
crypted = send(sorcery_config.crypted_password_attribute_name)
|
|
178
174
|
return crypted == pass if sorcery_config.encryption_provider.nil?
|
|
179
175
|
|
|
176
|
+
# Ensure encryption provider is using configured values
|
|
177
|
+
self.class.set_encryption_attributes
|
|
178
|
+
|
|
180
179
|
salt = send(sorcery_config.salt_attribute_name) unless sorcery_config.salt_attribute_name.nil?
|
|
181
180
|
|
|
182
181
|
sorcery_config.encryption_provider.matches?(crypted, pass, salt)
|
|
@@ -188,7 +187,9 @@ module Sorcery
|
|
|
188
187
|
# encrypts password with salt and saves it.
|
|
189
188
|
def encrypt_password
|
|
190
189
|
config = sorcery_config
|
|
191
|
-
|
|
190
|
+
unless config.salt_attribute_name.nil?
|
|
191
|
+
send(:"#{config.salt_attribute_name}=", new_salt = TemporaryToken.generate_random_token)
|
|
192
|
+
end
|
|
192
193
|
send(:"#{config.crypted_password_attribute_name}=", self.class.encrypt(send(config.password_attribute_name), new_salt))
|
|
193
194
|
end
|
|
194
195
|
|
|
@@ -48,9 +48,9 @@ module Sorcery
|
|
|
48
48
|
# Fix: replace default oauth2 options, specially to prevent the Faraday gem which
|
|
49
49
|
# concatenates with "/", removing the Facebook api version
|
|
50
50
|
options = {
|
|
51
|
-
site:
|
|
51
|
+
site: File.join(@site, api_version.to_s),
|
|
52
52
|
authorize_url: File.join(@auth_site, api_version.to_s, auth_path),
|
|
53
|
-
token_url:
|
|
53
|
+
token_url: token_url
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
@scope = access_permissions.present? ? access_permissions.join(',') : scope
|
|
@@ -26,7 +26,7 @@ module Sorcery
|
|
|
26
26
|
|
|
27
27
|
auth_hash(access_token).tap do |h|
|
|
28
28
|
h[:user_info] = JSON.parse(response.body).tap do |uih|
|
|
29
|
-
uih['email'] = primary_email(access_token) if scope
|
|
29
|
+
uih['email'] = primary_email(access_token) if scope&.include?('user')
|
|
30
30
|
end
|
|
31
31
|
h[:uid] = h[:user_info]['id']
|
|
32
32
|
end
|
|
@@ -48,10 +48,10 @@ module Sorcery
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def primary_email(access_token)
|
|
51
|
-
response = access_token.get(user_info_path
|
|
51
|
+
response = access_token.get("#{user_info_path}/emails")
|
|
52
52
|
emails = JSON.parse(response.body)
|
|
53
53
|
primary = emails.find { |i| i['primary'] }
|
|
54
|
-
primary && primary['email'] || emails.first && emails.first['email']
|
|
54
|
+
(primary && primary['email']) || (emails.first && emails.first['email'])
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
end
|
|
@@ -8,8 +8,7 @@ module Sorcery
|
|
|
8
8
|
# config.heroku.scope = "read"
|
|
9
9
|
# config.heroku.user_info_mapping = {:email => "email", :name => "email" }
|
|
10
10
|
|
|
11
|
-
# NOTE:
|
|
12
|
-
# The full path must be set for OAuth Callback URL when configuring the API Client Information on Heroku.
|
|
11
|
+
# NOTE: The full path must be set for OAuth Callback URL when configuring the API Client Information on Heroku.
|
|
13
12
|
|
|
14
13
|
class Heroku < Base
|
|
15
14
|
include Protocols::Oauth2
|
|
@@ -13,6 +13,7 @@ module Sorcery
|
|
|
13
13
|
:user_info_path, :site, :signature_method, :private_key_file, :callback_url
|
|
14
14
|
|
|
15
15
|
def initialize
|
|
16
|
+
super
|
|
16
17
|
@configuration = {
|
|
17
18
|
authorize_path: '/authorize',
|
|
18
19
|
request_token_path: '/request-token',
|
|
@@ -59,8 +60,8 @@ module Sorcery
|
|
|
59
60
|
# tries to login the user from access token
|
|
60
61
|
def process_callback(params, session)
|
|
61
62
|
args = {
|
|
62
|
-
oauth_verifier:
|
|
63
|
-
request_token:
|
|
63
|
+
oauth_verifier: params[:oauth_verifier],
|
|
64
|
+
request_token: session[:request_token],
|
|
64
65
|
request_token_secret: session[:request_token_secret]
|
|
65
66
|
}
|
|
66
67
|
|
|
@@ -38,11 +38,9 @@ module Sorcery
|
|
|
38
38
|
|
|
39
39
|
# overrides oauth2#authorize_url to add bot_prompt query.
|
|
40
40
|
def authorize_url(options = {})
|
|
41
|
-
options.
|
|
42
|
-
connection_opts: { params: { bot_prompt: bot_prompt } }
|
|
43
|
-
}) if bot_prompt.present?
|
|
41
|
+
options[:connection_opts] = { params: { bot_prompt: bot_prompt } } if bot_prompt.present?
|
|
44
42
|
|
|
45
|
-
super
|
|
43
|
+
super
|
|
46
44
|
end
|
|
47
45
|
|
|
48
46
|
# tries to login the user from access token
|
|
@@ -18,7 +18,7 @@ module Sorcery
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def get_user_hash(access_token)
|
|
21
|
-
response = access_token.get(user_info_path
|
|
21
|
+
response = access_token.get(user_info_path)
|
|
22
22
|
auth_hash(access_token).tap do |h|
|
|
23
23
|
h[:user_info] = JSON.parse(response.body)
|
|
24
24
|
h[:user_info]['email'] = h[:user_info]['user']['email']
|
|
@@ -44,8 +44,8 @@ module Sorcery
|
|
|
44
44
|
# tries to login the user from access token
|
|
45
45
|
def process_callback(params, session)
|
|
46
46
|
args = {
|
|
47
|
-
oauth_verifier:
|
|
48
|
-
request_token:
|
|
47
|
+
oauth_verifier: params[:oauth_verifier],
|
|
48
|
+
request_token: session[:request_token],
|
|
49
49
|
request_token_secret: session[:request_token_secret]
|
|
50
50
|
}
|
|
51
51
|
|
data/lib/sorcery/providers/vk.rb
CHANGED
|
@@ -26,10 +26,10 @@ module Sorcery
|
|
|
26
26
|
|
|
27
27
|
params = {
|
|
28
28
|
access_token: access_token.token,
|
|
29
|
-
uids:
|
|
30
|
-
fields:
|
|
31
|
-
scope:
|
|
32
|
-
v:
|
|
29
|
+
uids: access_token.params['user_id'],
|
|
30
|
+
fields: user_info_mapping.values.join(','),
|
|
31
|
+
scope: scope,
|
|
32
|
+
v: api_version.to_s
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
response = access_token.get(user_info_url, params: params)
|
|
@@ -13,6 +13,7 @@ module Sorcery
|
|
|
13
13
|
:user_info_path
|
|
14
14
|
|
|
15
15
|
def initialize
|
|
16
|
+
super
|
|
16
17
|
@configuration = {
|
|
17
18
|
site: 'https://api.xing.com/v1',
|
|
18
19
|
authorize_path: '/authorize',
|
|
@@ -48,8 +49,8 @@ module Sorcery
|
|
|
48
49
|
# tries to login the user from access token
|
|
49
50
|
def process_callback(params, session)
|
|
50
51
|
args = {
|
|
51
|
-
oauth_verifier:
|
|
52
|
-
request_token:
|
|
52
|
+
oauth_verifier: params[:oauth_verifier],
|
|
53
|
+
request_token: session[:request_token],
|
|
53
54
|
request_token_secret: session[:request_token_secret]
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -19,20 +19,16 @@ module Sorcery
|
|
|
19
19
|
|
|
20
20
|
# remove all plugin before_actions so they won't fail other tests.
|
|
21
21
|
# I don't like this way, but I didn't find another.
|
|
22
|
-
|
|
23
|
-
chain =
|
|
24
|
-
SorceryController._process_action_callbacks.send :chain
|
|
25
|
-
else
|
|
26
|
-
SorceryController._process_action_callbacks
|
|
27
|
-
end
|
|
28
|
-
|
|
22
|
+
callbacks = SorceryController._process_action_callbacks
|
|
23
|
+
chain = callbacks.send :chain
|
|
29
24
|
chain.delete_if { |c| SUBMODULES_AUTO_ADDED_CONTROLLER_FILTERS.include?(c.filter) }
|
|
25
|
+
callbacks.instance_variable_set(:@all_callbacks, nil)
|
|
26
|
+
callbacks.instance_variable_set(:@single_callbacks, {})
|
|
30
27
|
|
|
31
28
|
# configure
|
|
32
29
|
::Sorcery::Controller::Config.submodules = submodules
|
|
33
|
-
::Sorcery::Controller::Config.user_class = nil
|
|
34
|
-
ActionController::Base.send(:include, ::Sorcery::Controller)
|
|
35
30
|
::Sorcery::Controller::Config.user_class = 'User'
|
|
31
|
+
ActionController::Base.include(::Sorcery::Controller)
|
|
36
32
|
|
|
37
33
|
::Sorcery::Controller::Config.user_config do |user|
|
|
38
34
|
options.each do |property, value|
|
|
@@ -40,11 +36,6 @@ module Sorcery
|
|
|
40
36
|
end
|
|
41
37
|
end
|
|
42
38
|
User.authenticates_with_sorcery!
|
|
43
|
-
return unless defined?(DataMapper) && User.ancestors.include?(DataMapper::Resource)
|
|
44
|
-
|
|
45
|
-
DataMapper.auto_migrate!
|
|
46
|
-
User.finalize
|
|
47
|
-
Authentication.finalize
|
|
48
39
|
end
|
|
49
40
|
|
|
50
41
|
def sorcery_controller_property_set(property, value)
|
|
@@ -62,14 +53,6 @@ module Sorcery
|
|
|
62
53
|
def clear_user_without_logout
|
|
63
54
|
subject.instance_variable_set(:@current_user, nil)
|
|
64
55
|
end
|
|
65
|
-
|
|
66
|
-
if ::Rails.version < '5.0.0'
|
|
67
|
-
%w[get post put].each do |method|
|
|
68
|
-
define_method(method) do |action, options = {}|
|
|
69
|
-
super action, options[:params] || {}, options[:session]
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
56
|
end
|
|
74
57
|
end
|
|
75
58
|
end
|
|
@@ -17,14 +17,14 @@ module Sorcery
|
|
|
17
17
|
# a patch to fix a bug in testing that happens when you 'destroy' a session twice.
|
|
18
18
|
# After the first destroy, the session is an ordinary hash, and then when destroy
|
|
19
19
|
# is called again there's an exception.
|
|
20
|
-
class ::Hash
|
|
20
|
+
class ::Hash
|
|
21
21
|
def destroy
|
|
22
22
|
clear
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def build_new_user(attributes_hash = nil)
|
|
27
|
-
user_attributes_hash = attributes_hash || { username: 'gizmo', email: 'bla@
|
|
27
|
+
user_attributes_hash = attributes_hash || { username: 'gizmo', email: 'bla@example.com', password: 'secret' }
|
|
28
28
|
@user = User.new(user_attributes_hash)
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -58,8 +58,8 @@ module Sorcery
|
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
def update_model(&
|
|
62
|
-
User.class_exec(&
|
|
61
|
+
def update_model(&)
|
|
62
|
+
User.class_exec(&)
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
private
|
|
@@ -70,8 +70,6 @@ module Sorcery
|
|
|
70
70
|
User && Object.send(:remove_const, 'User')
|
|
71
71
|
load 'user.rb'
|
|
72
72
|
|
|
73
|
-
return unless User.respond_to?(:reset_column_information)
|
|
74
|
-
|
|
75
73
|
User.reset_column_information
|
|
76
74
|
end
|
|
77
75
|
end
|
|
@@ -10,7 +10,7 @@ module Sorcery
|
|
|
10
10
|
|
|
11
11
|
username_attr = user.sorcery_config.username_attribute_names.first
|
|
12
12
|
username = user.send(username_attr)
|
|
13
|
-
page.driver.send(http_method, route,
|
|
13
|
+
page.driver.send(http_method, route, "#{username_attr}": username, password: 'secret')
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
# Accepts route and HTTP method arguments
|
|
@@ -4,7 +4,7 @@ module Sorcery
|
|
|
4
4
|
module Request
|
|
5
5
|
# Accepts arguments for user to login, the password, route to use and HTTP method
|
|
6
6
|
# Defaults - @user, 'secret', 'user_sessions_url' and http_method: POST
|
|
7
|
-
def login_user(user = nil, password = 'secret', route = nil, http_method = :post)
|
|
7
|
+
def login_user(user = nil, password = 'secret', route = nil, http_method = :post) # rubocop:disable Metrics/ParameterLists
|
|
8
8
|
user ||= @user
|
|
9
9
|
route ||= user_sessions_url
|
|
10
10
|
|
data/lib/sorcery/version.rb
CHANGED
data/lib/sorcery.rb
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
require 'sorcery/version'
|
|
2
|
+
require 'sorcery/errors'
|
|
2
3
|
|
|
3
4
|
module Sorcery
|
|
5
|
+
def self.deprecator
|
|
6
|
+
@deprecator ||= ActiveSupport::Deprecation.new(nil, 'Sorcery')
|
|
7
|
+
end
|
|
8
|
+
|
|
4
9
|
require 'sorcery/model'
|
|
5
10
|
|
|
6
11
|
module Adapters
|
|
@@ -82,7 +87,7 @@ module Sorcery
|
|
|
82
87
|
|
|
83
88
|
if defined?(Mongoid::Document)
|
|
84
89
|
require 'sorcery/adapters/mongoid_adapter'
|
|
85
|
-
Mongoid::Document::ClassMethods.
|
|
90
|
+
Mongoid::Document::ClassMethods.include Sorcery::Model
|
|
86
91
|
|
|
87
92
|
Mongoid::Document.send :define_method, :sorcery_adapter do
|
|
88
93
|
@sorcery_adapter ||= Sorcery::Adapters::MongoidAdapter.new(self)
|