devise 2.2.8 → 3.0.0.rc
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of devise might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.travis.yml +2 -17
- data/CHANGELOG.rdoc +4 -20
- data/Gemfile +3 -4
- data/Gemfile.lock +68 -64
- data/README.md +50 -30
- data/app/controllers/devise/confirmations_controller.rb +1 -2
- data/app/controllers/devise/passwords_controller.rb +1 -1
- data/app/controllers/devise/registrations_controller.rb +13 -6
- data/app/controllers/devise/sessions_controller.rb +5 -1
- data/app/controllers/devise/unlocks_controller.rb +1 -1
- data/app/controllers/devise_controller.rb +4 -21
- data/devise.gemspec +1 -1
- data/gemfiles/{Gemfile.rails-3.1.x → Gemfile.rails-3.2.x} +3 -7
- data/gemfiles/{Gemfile.rails-3.1.x.lock → Gemfile.rails-3.2.x.lock} +47 -58
- data/lib/devise.rb +8 -10
- data/lib/devise/controllers/helpers.rb +11 -0
- data/lib/devise/controllers/rememberable.rb +0 -1
- data/lib/devise/models/authenticatable.rb +0 -1
- data/lib/devise/models/confirmable.rb +5 -0
- data/lib/devise/parameter_sanitizer.rb +59 -0
- data/lib/devise/rails/warden_compat.rb +2 -9
- data/lib/devise/strategies/database_authenticatable.rb +3 -6
- data/lib/devise/version.rb +1 -1
- data/lib/generators/active_record/devise_generator.rb +1 -4
- data/lib/generators/templates/devise.rb +0 -6
- data/test/controllers/helpers_test.rb +1 -1
- data/test/controllers/internal_helpers_test.rb +13 -3
- data/test/controllers/passwords_controller_test.rb +1 -1
- data/test/generators/active_record_generator_test.rb +1 -3
- data/test/integration/authenticatable_test.rb +3 -17
- data/test/integration/http_authenticatable_test.rb +1 -1
- data/test/integration/recoverable_test.rb +11 -1
- data/test/integration/registerable_test.rb +8 -6
- data/test/integration/rememberable_test.rb +13 -15
- data/test/models/database_authenticatable_test.rb +0 -13
- data/test/models/validatable_test.rb +12 -2
- data/test/omniauth/url_helpers_test.rb +4 -1
- data/test/orm/active_record.rb +1 -0
- data/test/parameter_sanitizer_test.rb +51 -0
- data/test/rails_app/Rakefile +0 -4
- data/test/rails_app/app/mongoid/shim.rb +2 -3
- data/test/rails_app/bin/bundle +3 -0
- data/test/rails_app/bin/rails +4 -0
- data/test/rails_app/bin/rake +4 -0
- data/test/rails_app/config/application.rb +1 -2
- data/test/rails_app/config/boot.rb +3 -3
- data/test/rails_app/config/environment.rb +2 -2
- data/test/rails_app/config/environments/development.rb +23 -7
- data/test/rails_app/config/environments/production.rb +68 -17
- data/test/rails_app/config/environments/test.rb +18 -15
- data/test/rails_app/config/initializers/secret_token.rb +8 -2
- data/test/rails_app/config/initializers/session_store.rb +1 -0
- data/test/rails_app/config/routes.rb +1 -1
- data/test/rails_app/lib/shared_user.rb +0 -1
- data/test/routes_test.rb +22 -20
- data/test/test_helper.rb +7 -0
- data/test/test_models.rb +0 -1
- metadata +31 -27
- data/lib/devise/hooks/csrf_cleaner.rb +0 -5
- data/test/rails_app/script/rails +0 -10
@@ -5,7 +5,7 @@ class Devise::SessionsController < DeviseController
|
|
5
5
|
|
6
6
|
# GET /resource/sign_in
|
7
7
|
def new
|
8
|
-
self.resource =
|
8
|
+
self.resource = resource_class.new(sign_in_params)
|
9
9
|
clean_up_passwords(resource)
|
10
10
|
respond_with(resource, serialize_options(resource))
|
11
11
|
end
|
@@ -34,6 +34,10 @@ class Devise::SessionsController < DeviseController
|
|
34
34
|
|
35
35
|
protected
|
36
36
|
|
37
|
+
def sign_in_params
|
38
|
+
devise_parameter_sanitizer.for(:sign_in)
|
39
|
+
end
|
40
|
+
|
37
41
|
def serialize_options(resource)
|
38
42
|
methods = resource_class.authentication_keys.dup
|
39
43
|
methods = methods.keys if methods.is_a?(Hash)
|
@@ -28,10 +28,6 @@ class DeviseController < Devise.parent_controller.constantize
|
|
28
28
|
devise_mapping.to
|
29
29
|
end
|
30
30
|
|
31
|
-
def resource_params
|
32
|
-
params[resource_name]
|
33
|
-
end
|
34
|
-
|
35
31
|
# Returns a signed in resource from session (if one exists)
|
36
32
|
def signed_in_resource
|
37
33
|
warden.authenticate(:scope => resource_name)
|
@@ -93,23 +89,6 @@ MESSAGE
|
|
93
89
|
instance_variable_set(:"@#{resource_name}", new_resource)
|
94
90
|
end
|
95
91
|
|
96
|
-
# Build a devise resource.
|
97
|
-
# Assignment bypasses attribute protection when :unsafe option is passed
|
98
|
-
def build_resource(hash = nil, options = {})
|
99
|
-
hash ||= resource_params || {}
|
100
|
-
|
101
|
-
if options[:unsafe]
|
102
|
-
self.resource = resource_class.new.tap do |resource|
|
103
|
-
hash.each do |key, value|
|
104
|
-
setter = :"#{key}="
|
105
|
-
resource.send(setter, value) if resource.respond_to?(setter)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
else
|
109
|
-
self.resource = resource_class.new(hash)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
92
|
# Helper for use in before_filters where no authentication is required.
|
114
93
|
#
|
115
94
|
# Example:
|
@@ -186,4 +165,8 @@ MESSAGE
|
|
186
165
|
format.any(*navigational_formats, &block)
|
187
166
|
end
|
188
167
|
end
|
168
|
+
|
169
|
+
def resource_params
|
170
|
+
params.fetch(resource_name, {})
|
171
|
+
end
|
189
172
|
end
|
data/devise.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
|
3
|
+
gemspec :path => '..'
|
4
4
|
|
5
|
-
gem "rails", "~> 3.
|
5
|
+
gem "rails", "~> 3.2.6"
|
6
6
|
gem "omniauth", "~> 1.0.0"
|
7
7
|
gem "omniauth-oauth2", "~> 1.0.0"
|
8
8
|
gem "rdoc"
|
@@ -12,10 +12,6 @@ group :test do
|
|
12
12
|
gem "omniauth-openid", "~> 1.0.1"
|
13
13
|
gem "webrat", "0.7.3", :require => false
|
14
14
|
gem "mocha", "~> 0.13.1", :require => false
|
15
|
-
|
16
|
-
platforms :mri_18 do
|
17
|
-
gem "ruby-debug", ">= 0.10.3"
|
18
|
-
end
|
19
15
|
end
|
20
16
|
|
21
17
|
platforms :jruby do
|
@@ -28,7 +24,7 @@ platforms :ruby do
|
|
28
24
|
gem "sqlite3"
|
29
25
|
end
|
30
26
|
|
31
|
-
platforms :mri_19 do
|
27
|
+
platforms :mri_19, :mri_20 do
|
32
28
|
group :mongoid do
|
33
29
|
gem "mongoid", "~> 3.0"
|
34
30
|
end
|
@@ -1,60 +1,57 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
devise (
|
4
|
+
devise (3.0.0.rc)
|
5
5
|
bcrypt-ruby (~> 3.0)
|
6
6
|
orm_adapter (~> 0.1)
|
7
|
-
railties (
|
7
|
+
railties (>= 3.2.6, < 5)
|
8
8
|
warden (~> 1.2.1)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
actionmailer (3.
|
14
|
-
actionpack (= 3.
|
15
|
-
mail (~> 2.
|
16
|
-
actionpack (3.
|
17
|
-
activemodel (= 3.
|
18
|
-
activesupport (= 3.
|
13
|
+
actionmailer (3.2.13)
|
14
|
+
actionpack (= 3.2.13)
|
15
|
+
mail (~> 2.5.3)
|
16
|
+
actionpack (3.2.13)
|
17
|
+
activemodel (= 3.2.13)
|
18
|
+
activesupport (= 3.2.13)
|
19
19
|
builder (~> 3.0.0)
|
20
20
|
erubis (~> 2.7.0)
|
21
|
-
|
22
|
-
rack (~> 1.
|
21
|
+
journey (~> 1.0.4)
|
22
|
+
rack (~> 1.4.5)
|
23
23
|
rack-cache (~> 1.2)
|
24
|
-
rack-mount (~> 0.8.2)
|
25
24
|
rack-test (~> 0.6.1)
|
26
|
-
sprockets (~> 2.
|
27
|
-
activemodel (3.
|
28
|
-
activesupport (= 3.
|
25
|
+
sprockets (~> 2.2.1)
|
26
|
+
activemodel (3.2.13)
|
27
|
+
activesupport (= 3.2.13)
|
29
28
|
builder (~> 3.0.0)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
arel (~> 2.2.3)
|
29
|
+
activerecord (3.2.13)
|
30
|
+
activemodel (= 3.2.13)
|
31
|
+
activesupport (= 3.2.13)
|
32
|
+
arel (~> 3.0.2)
|
35
33
|
tzinfo (~> 0.3.29)
|
36
|
-
activeresource (3.
|
37
|
-
activemodel (= 3.
|
38
|
-
activesupport (= 3.
|
39
|
-
activesupport (3.
|
34
|
+
activeresource (3.2.13)
|
35
|
+
activemodel (= 3.2.13)
|
36
|
+
activesupport (= 3.2.13)
|
37
|
+
activesupport (3.2.13)
|
38
|
+
i18n (= 0.6.1)
|
40
39
|
multi_json (~> 1.0)
|
41
|
-
arel (
|
42
|
-
bcrypt-ruby (3.1
|
40
|
+
arel (3.0.2)
|
41
|
+
bcrypt-ruby (3.0.1)
|
43
42
|
builder (3.0.4)
|
44
|
-
columnize (0.3.6)
|
45
43
|
erubis (2.7.0)
|
46
44
|
faraday (0.8.7)
|
47
45
|
multipart-post (~> 1.1)
|
48
46
|
hashie (1.2.0)
|
49
47
|
hike (1.2.2)
|
50
48
|
httpauth (0.2.0)
|
51
|
-
i18n (0.6.
|
49
|
+
i18n (0.6.1)
|
50
|
+
journey (1.0.4)
|
52
51
|
json (1.7.7)
|
53
52
|
jwt (0.1.8)
|
54
53
|
multi_json (>= 1.5)
|
55
|
-
|
56
|
-
rbx-require-relative (> 0.0.4)
|
57
|
-
mail (2.4.4)
|
54
|
+
mail (2.5.3)
|
58
55
|
i18n (>= 0.4.0)
|
59
56
|
mime-types (~> 1.16)
|
60
57
|
treetop (~> 1.4.8)
|
@@ -62,9 +59,9 @@ GEM
|
|
62
59
|
mime-types (1.23)
|
63
60
|
mocha (0.13.3)
|
64
61
|
metaclass (~> 0.0.1)
|
65
|
-
mongoid (3.
|
66
|
-
activemodel (~> 3.
|
67
|
-
moped (~> 1.2)
|
62
|
+
mongoid (3.1.3)
|
63
|
+
activemodel (~> 3.2)
|
64
|
+
moped (~> 1.4.2)
|
68
65
|
origin (~> 1.0)
|
69
66
|
tzinfo (~> 0.3.22)
|
70
67
|
moped (1.4.5)
|
@@ -91,11 +88,9 @@ GEM
|
|
91
88
|
origin (1.1.0)
|
92
89
|
orm_adapter (0.4.0)
|
93
90
|
polyglot (0.3.3)
|
94
|
-
rack (1.
|
91
|
+
rack (1.4.5)
|
95
92
|
rack-cache (1.2)
|
96
93
|
rack (>= 0.4)
|
97
|
-
rack-mount (0.8.3)
|
98
|
-
rack (>= 1.0.0)
|
99
94
|
rack-openid (1.3.1)
|
100
95
|
rack (>= 1.1.0)
|
101
96
|
ruby-openid (>= 2.1.8)
|
@@ -103,43 +98,38 @@ GEM
|
|
103
98
|
rack
|
104
99
|
rack-test (0.6.2)
|
105
100
|
rack (>= 1.0)
|
106
|
-
rails (3.
|
107
|
-
actionmailer (= 3.
|
108
|
-
actionpack (= 3.
|
109
|
-
activerecord (= 3.
|
110
|
-
activeresource (= 3.
|
111
|
-
activesupport (= 3.
|
101
|
+
rails (3.2.13)
|
102
|
+
actionmailer (= 3.2.13)
|
103
|
+
actionpack (= 3.2.13)
|
104
|
+
activerecord (= 3.2.13)
|
105
|
+
activeresource (= 3.2.13)
|
106
|
+
activesupport (= 3.2.13)
|
112
107
|
bundler (~> 1.0)
|
113
|
-
railties (= 3.
|
114
|
-
railties (3.
|
115
|
-
actionpack (= 3.
|
116
|
-
activesupport (= 3.
|
108
|
+
railties (= 3.2.13)
|
109
|
+
railties (3.2.13)
|
110
|
+
actionpack (= 3.2.13)
|
111
|
+
activesupport (= 3.2.13)
|
117
112
|
rack-ssl (~> 1.3.2)
|
118
113
|
rake (>= 0.8.7)
|
119
114
|
rdoc (~> 3.4)
|
120
|
-
thor (
|
115
|
+
thor (>= 0.14.6, < 2.0)
|
121
116
|
rake (10.0.4)
|
122
|
-
rbx-require-relative (0.0.9)
|
123
117
|
rdoc (3.12.2)
|
124
118
|
json (~> 1.4)
|
125
|
-
ruby-debug (0.10.4)
|
126
|
-
columnize (>= 0.1)
|
127
|
-
ruby-debug-base (~> 0.10.4.0)
|
128
|
-
ruby-debug-base (0.10.4)
|
129
|
-
linecache (>= 0.3)
|
130
119
|
ruby-openid (2.2.3)
|
131
|
-
sprockets (2.
|
120
|
+
sprockets (2.2.2)
|
132
121
|
hike (~> 1.2)
|
122
|
+
multi_json (~> 1.0)
|
133
123
|
rack (~> 1.0)
|
134
124
|
tilt (~> 1.1, != 1.3.0)
|
135
125
|
sqlite3 (1.3.7)
|
136
|
-
thor (0.
|
126
|
+
thor (0.18.1)
|
137
127
|
tilt (1.4.0)
|
138
128
|
treetop (1.4.12)
|
139
129
|
polyglot
|
140
130
|
polyglot (>= 0.3.1)
|
141
131
|
tzinfo (0.3.37)
|
142
|
-
warden (1.2.
|
132
|
+
warden (1.2.1)
|
143
133
|
rack (>= 1.0)
|
144
134
|
webrat (0.7.3)
|
145
135
|
nokogiri (>= 1.2.0)
|
@@ -160,8 +150,7 @@ DEPENDENCIES
|
|
160
150
|
omniauth-facebook
|
161
151
|
omniauth-oauth2 (~> 1.0.0)
|
162
152
|
omniauth-openid (~> 1.0.1)
|
163
|
-
rails (~> 3.
|
153
|
+
rails (~> 3.2.6)
|
164
154
|
rdoc
|
165
|
-
ruby-debug (>= 0.10.3)
|
166
155
|
sqlite3
|
167
156
|
webrat (= 0.7.3)
|
data/lib/devise.rb
CHANGED
@@ -6,12 +6,14 @@ require 'set'
|
|
6
6
|
require 'securerandom'
|
7
7
|
|
8
8
|
module Devise
|
9
|
-
autoload :Delegator,
|
10
|
-
autoload :FailureApp,
|
11
|
-
autoload :OmniAuth,
|
12
|
-
autoload :ParamFilter,
|
13
|
-
autoload :
|
14
|
-
autoload :
|
9
|
+
autoload :Delegator, 'devise/delegator'
|
10
|
+
autoload :FailureApp, 'devise/failure_app'
|
11
|
+
autoload :OmniAuth, 'devise/omniauth'
|
12
|
+
autoload :ParamFilter, 'devise/param_filter'
|
13
|
+
autoload :BaseSanitizer, 'devise/parameter_sanitizer'
|
14
|
+
autoload :ParameterSanitizer, 'devise/parameter_sanitizer'
|
15
|
+
autoload :TestHelpers, 'devise/test_helpers'
|
16
|
+
autoload :TimeInflector, 'devise/time_inflector'
|
15
17
|
|
16
18
|
module Controllers
|
17
19
|
autoload :Helpers, 'devise/controllers/helpers'
|
@@ -221,10 +223,6 @@ module Devise
|
|
221
223
|
mattr_accessor :omniauth_path_prefix
|
222
224
|
@@omniauth_path_prefix = nil
|
223
225
|
|
224
|
-
# Set if we should clean up the CSRF Token on authentication
|
225
|
-
mattr_accessor :clean_up_csrf_token_on_authentication
|
226
|
-
@@clean_up_csrf_token_on_authentication = true
|
227
|
-
|
228
226
|
def self.encryptor=(value)
|
229
227
|
warn "\n[DEVISE] To select a encryption which isn't bcrypt, you should use devise-encryptable gem.\n"
|
230
228
|
end
|
@@ -80,6 +80,17 @@ module Devise
|
|
80
80
|
is_a?(DeviseController)
|
81
81
|
end
|
82
82
|
|
83
|
+
# Setup a param sanitizer to filter parameters using strong_parameters. See
|
84
|
+
# lib/devise/parameter_sanitizer.rb for more info. Override this
|
85
|
+
# method in your application controller to use your own parameter sanitizer.
|
86
|
+
def devise_parameter_sanitizer
|
87
|
+
@devise_parameter_sanitizer ||= if defined?(ActionController::StrongParameters)
|
88
|
+
Devise::ParameterSanitizer.new(resource_class, resource_name, params)
|
89
|
+
else
|
90
|
+
Devise::BaseSanitizer.new(resource_class, resource_name, params)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
83
94
|
# Tell warden that params authentication is allowed for that specific page.
|
84
95
|
def allow_params_authentication!
|
85
96
|
request.env["devise.allow_params_authentication"] = true
|
@@ -21,7 +21,6 @@ module Devise
|
|
21
21
|
|
22
22
|
# Remembers the given resource by setting up a cookie
|
23
23
|
def remember_me(resource)
|
24
|
-
return if env["devise.skip_storage"]
|
25
24
|
scope = Devise::Mapping.find_scope!(resource)
|
26
25
|
resource.remember_me!(resource.extend_remember_period)
|
27
26
|
cookies.signed[remember_key(resource, scope)] = remember_cookie_values(resource)
|
@@ -215,6 +215,11 @@ module Devise
|
|
215
215
|
generate_confirmation_token && save(:validate => false)
|
216
216
|
end
|
217
217
|
|
218
|
+
def after_password_reset
|
219
|
+
super
|
220
|
+
confirm! unless confirmed?
|
221
|
+
end
|
222
|
+
|
218
223
|
def postpone_email_change_until_confirmation
|
219
224
|
@reconfirmation_required = true
|
220
225
|
self.unconfirmed_email = self.email
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Devise
|
2
|
+
class BaseSanitizer
|
3
|
+
attr_reader :params, :resource_name, :resource_class
|
4
|
+
|
5
|
+
def initialize(resource_class, resource_name, params)
|
6
|
+
@resource_class = resource_class
|
7
|
+
@resource_name = resource_name
|
8
|
+
@params = params
|
9
|
+
@blocks = Hash.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def for(kind, &block)
|
13
|
+
if block_given?
|
14
|
+
@blocks[kind] = block
|
15
|
+
else
|
16
|
+
block = @blocks[kind]
|
17
|
+
block ? block.call(default_params) : fallback_for(kind)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def fallback_for(kind)
|
24
|
+
default_params
|
25
|
+
end
|
26
|
+
|
27
|
+
def default_params
|
28
|
+
params.fetch(resource_name, {})
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class ParameterSanitizer < BaseSanitizer
|
33
|
+
private
|
34
|
+
|
35
|
+
def fallback_for(kind)
|
36
|
+
if respond_to?(kind, true)
|
37
|
+
send(kind)
|
38
|
+
else
|
39
|
+
raise NotImplementedError, "Devise Parameter Sanitizer doesn't know how to sanitize parameters for #{kind}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def sign_in
|
44
|
+
default_params.permit(auth_keys)
|
45
|
+
end
|
46
|
+
|
47
|
+
def sign_up
|
48
|
+
default_params.permit(auth_keys + [:password, :password_confirmation])
|
49
|
+
end
|
50
|
+
|
51
|
+
def account_update
|
52
|
+
default_params.permit(auth_keys + [:password, :password_confirmation, :current_password])
|
53
|
+
end
|
54
|
+
|
55
|
+
def auth_keys
|
56
|
+
resource_class.authentication_keys
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -3,16 +3,9 @@ module Warden::Mixins::Common
|
|
3
3
|
@request ||= ActionDispatch::Request.new(env)
|
4
4
|
end
|
5
5
|
|
6
|
-
|
7
|
-
defined?(ActionController::RequestForgeryProtection::ProtectionMethods::NullSession::NullSessionHash) ?
|
8
|
-
ActionController::RequestForgeryProtection::ProtectionMethods::NullSession::NullSessionHash : nil
|
9
|
-
|
6
|
+
# This is called internally by Warden on logout
|
10
7
|
def reset_session!
|
11
|
-
|
12
|
-
# This is a bug that needs to be fixed in Rails.
|
13
|
-
unless NULL_STORE && request.session.is_a?(NULL_STORE)
|
14
|
-
request.reset_session
|
15
|
-
end
|
8
|
+
request.reset_session
|
16
9
|
end
|
17
10
|
|
18
11
|
def cookies
|