devise 2.1.2 → 3.5.10
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 +39 -10
- data/.yardopts +9 -0
- data/{CHANGELOG.rdoc → CHANGELOG.md} +445 -112
- data/CODE_OF_CONDUCT.md +22 -0
- data/CONTRIBUTING.md +16 -0
- data/Gemfile +10 -15
- data/Gemfile.lock +151 -129
- data/MIT-LICENSE +1 -1
- data/README.md +256 -96
- data/Rakefile +4 -2
- data/app/controllers/devise/confirmations_controller.rb +15 -7
- data/app/controllers/devise/omniauth_callbacks_controller.rb +6 -2
- data/app/controllers/devise/passwords_controller.rb +33 -9
- data/app/controllers/devise/registrations_controller.rb +66 -26
- data/app/controllers/devise/sessions_controller.rb +52 -21
- data/app/controllers/devise/unlocks_controller.rb +11 -6
- data/app/controllers/devise_controller.rb +65 -58
- data/app/helpers/devise_helper.rb +2 -2
- data/app/mailers/devise/mailer.rb +19 -10
- data/app/views/devise/confirmations/new.html.erb +8 -4
- data/app/views/devise/mailer/confirmation_instructions.html.erb +2 -2
- data/app/views/devise/mailer/password_change.html.erb +3 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +2 -2
- data/app/views/devise/mailer/unlock_instructions.html.erb +2 -2
- data/app/views/devise/passwords/edit.html.erb +15 -6
- data/app/views/devise/passwords/new.html.erb +8 -4
- data/app/views/devise/registrations/edit.html.erb +29 -15
- data/app/views/devise/registrations/new.html.erb +19 -8
- data/app/views/devise/sessions/new.html.erb +17 -8
- data/app/views/devise/shared/{_links.erb → _links.html.erb} +4 -4
- data/app/views/devise/unlocks/new.html.erb +8 -4
- data/config/locales/en.yml +51 -47
- data/devise.gemspec +8 -6
- data/devise.png +0 -0
- data/gemfiles/Gemfile.rails-3.2-stable +29 -0
- data/gemfiles/Gemfile.rails-3.2-stable.lock +172 -0
- data/gemfiles/Gemfile.rails-4.0-stable +30 -0
- data/gemfiles/Gemfile.rails-4.0-stable.lock +166 -0
- data/gemfiles/Gemfile.rails-4.1-stable +30 -0
- data/gemfiles/Gemfile.rails-4.1-stable.lock +171 -0
- data/gemfiles/Gemfile.rails-4.2-stable +30 -0
- data/gemfiles/Gemfile.rails-4.2-stable.lock +193 -0
- data/lib/devise/controllers/helpers.rb +126 -108
- data/lib/devise/controllers/rememberable.rb +19 -17
- data/lib/devise/controllers/scoped_views.rb +1 -1
- data/lib/devise/controllers/sign_in_out.rb +96 -0
- data/lib/devise/controllers/store_location.rb +58 -0
- data/lib/devise/controllers/url_helpers.rb +7 -7
- data/lib/devise/encryptor.rb +22 -0
- data/lib/devise/failure_app.rb +85 -25
- data/lib/devise/hooks/activatable.rb +5 -6
- data/lib/devise/hooks/csrf_cleaner.rb +7 -0
- data/lib/devise/hooks/forgetable.rb +1 -1
- data/lib/devise/hooks/lockable.rb +2 -2
- data/lib/devise/hooks/proxy.rb +21 -0
- data/lib/devise/hooks/rememberable.rb +5 -4
- data/lib/devise/hooks/timeoutable.rb +16 -8
- data/lib/devise/hooks/trackable.rb +1 -1
- data/lib/devise/mailers/helpers.rb +27 -23
- data/lib/devise/mapping.rb +11 -7
- data/lib/devise/models/authenticatable.rb +82 -66
- data/lib/devise/models/confirmable.rb +142 -55
- data/lib/devise/models/database_authenticatable.rb +59 -15
- data/lib/devise/models/lockable.rb +41 -30
- data/lib/devise/models/omniauthable.rb +3 -3
- data/lib/devise/models/recoverable.rb +56 -41
- data/lib/devise/models/rememberable.rb +65 -27
- data/lib/devise/models/timeoutable.rb +2 -8
- data/lib/devise/models/trackable.rb +6 -4
- data/lib/devise/models/validatable.rb +9 -9
- data/lib/devise/models.rb +4 -13
- data/lib/devise/modules.rb +10 -11
- data/lib/devise/omniauth/url_helpers.rb +2 -2
- data/lib/devise/orm/active_record.rb +1 -1
- data/lib/devise/orm/mongoid.rb +1 -1
- data/lib/devise/{param_filter.rb → parameter_filter.rb} +10 -11
- data/lib/devise/parameter_sanitizer.rb +99 -0
- data/lib/devise/rails/routes.rb +173 -115
- data/lib/devise/rails/warden_compat.rb +10 -31
- data/lib/devise/rails.rb +14 -12
- data/lib/devise/strategies/authenticatable.rb +26 -26
- data/lib/devise/strategies/base.rb +1 -1
- data/lib/devise/strategies/database_authenticatable.rb +8 -4
- data/lib/devise/strategies/rememberable.rb +15 -5
- data/lib/devise/test_helpers.rb +7 -5
- data/lib/devise/time_inflector.rb +14 -0
- data/lib/devise/token_generator.rb +70 -0
- data/lib/devise/version.rb +1 -1
- data/lib/devise.rb +110 -52
- data/lib/generators/active_record/devise_generator.rb +34 -18
- data/lib/generators/active_record/templates/migration.rb +5 -6
- data/lib/generators/active_record/templates/migration_existing.rb +5 -6
- data/lib/generators/devise/controllers_generator.rb +44 -0
- data/lib/generators/devise/devise_generator.rb +5 -3
- data/lib/generators/devise/install_generator.rb +5 -0
- data/lib/generators/devise/orm_helpers.rb +25 -6
- data/lib/generators/devise/views_generator.rb +52 -22
- data/lib/generators/mongoid/devise_generator.rb +21 -26
- data/lib/generators/templates/README +9 -5
- data/lib/generators/templates/controllers/README +14 -0
- data/lib/generators/templates/controllers/confirmations_controller.rb +28 -0
- data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +28 -0
- data/lib/generators/templates/controllers/passwords_controller.rb +32 -0
- data/lib/generators/templates/controllers/registrations_controller.rb +60 -0
- data/lib/generators/templates/controllers/sessions_controller.rb +25 -0
- data/lib/generators/templates/controllers/unlocks_controller.rb +28 -0
- data/lib/generators/templates/devise.rb +80 -43
- data/lib/generators/templates/markerb/confirmation_instructions.markerb +2 -2
- data/lib/generators/templates/markerb/password_change.markerb +3 -0
- data/lib/generators/templates/markerb/reset_password_instructions.markerb +1 -1
- data/lib/generators/templates/markerb/unlock_instructions.markerb +2 -2
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +3 -2
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +2 -2
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +11 -6
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/sessions/new.html.erb +6 -6
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +3 -2
- data/script/cached-bundle +49 -0
- data/script/s3-put +71 -0
- data/test/controllers/custom_registrations_controller_test.rb +40 -0
- data/test/controllers/helper_methods_test.rb +21 -0
- data/test/controllers/helpers_test.rb +95 -32
- data/test/controllers/inherited_controller_i18n_messages_test.rb +51 -0
- data/test/controllers/internal_helpers_test.rb +39 -14
- data/test/controllers/load_hooks_controller_test.rb +19 -0
- data/test/controllers/passwords_controller_test.rb +31 -0
- data/test/controllers/sessions_controller_test.rb +66 -6
- data/test/controllers/url_helpers_test.rb +10 -4
- data/test/delegator_test.rb +1 -1
- data/test/devise_test.rb +45 -10
- data/test/failure_app_test.rb +121 -27
- data/test/generators/active_record_generator_test.rb +48 -8
- data/test/generators/controllers_generator_test.rb +48 -0
- data/test/generators/devise_generator_test.rb +2 -2
- data/test/generators/mongoid_generator_test.rb +3 -3
- data/test/generators/views_generator_test.rb +54 -3
- data/test/helpers/devise_helper_test.rb +18 -20
- data/test/integration/authenticatable_test.rb +161 -65
- data/test/integration/confirmable_test.rb +146 -77
- data/test/integration/database_authenticatable_test.rb +43 -30
- data/test/integration/http_authenticatable_test.rb +30 -22
- data/test/integration/lockable_test.rb +64 -49
- data/test/integration/omniauthable_test.rb +17 -15
- data/test/integration/recoverable_test.rb +111 -70
- data/test/integration/registerable_test.rb +114 -79
- data/test/integration/rememberable_test.rb +87 -31
- data/test/integration/timeoutable_test.rb +77 -33
- data/test/integration/trackable_test.rb +5 -5
- data/test/mailers/confirmation_instructions_test.rb +28 -8
- data/test/mailers/reset_password_instructions_test.rb +21 -8
- data/test/mailers/unlock_instructions_test.rb +20 -6
- data/test/mapping_test.rb +12 -5
- data/test/models/authenticatable_test.rb +17 -1
- data/test/models/confirmable_test.rb +216 -62
- data/test/models/database_authenticatable_test.rb +129 -49
- data/test/models/lockable_test.rb +132 -45
- data/test/models/recoverable_test.rb +100 -54
- data/test/models/rememberable_test.rb +89 -94
- data/test/models/serializable_test.rb +12 -11
- data/test/models/timeoutable_test.rb +6 -1
- data/test/models/trackable_test.rb +28 -0
- data/test/models/validatable_test.rb +31 -21
- data/test/models_test.rb +22 -48
- data/test/omniauth/config_test.rb +4 -4
- data/test/omniauth/url_helpers_test.rb +7 -4
- data/test/orm/active_record.rb +1 -0
- data/test/orm/mongoid.rb +2 -3
- data/test/parameter_sanitizer_test.rb +81 -0
- data/test/rails_app/Rakefile +0 -4
- data/test/rails_app/app/active_record/shim.rb +1 -1
- data/test/rails_app/app/active_record/user_on_engine.rb +7 -0
- data/test/rails_app/app/active_record/user_on_main_app.rb +7 -0
- data/test/rails_app/app/active_record/user_without_email.rb +8 -0
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +1 -1
- data/test/rails_app/app/controllers/admins_controller.rb +0 -5
- data/test/rails_app/app/controllers/application_controller.rb +6 -2
- data/test/rails_app/app/controllers/application_with_fake_engine.rb +30 -0
- data/test/rails_app/app/controllers/custom/registrations_controller.rb +31 -0
- data/test/rails_app/app/controllers/home_controller.rb +1 -1
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +1 -1
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +1 -1
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +4 -4
- data/test/rails_app/app/controllers/users_controller.rb +12 -4
- data/test/rails_app/app/mailers/users/from_proc_mailer.rb +3 -0
- data/test/rails_app/app/mailers/users/mailer.rb +1 -1
- data/test/rails_app/app/mailers/users/reply_to_mailer.rb +4 -0
- data/test/rails_app/app/mongoid/admin.rb +12 -10
- data/test/rails_app/app/mongoid/shim.rb +4 -5
- data/test/rails_app/app/mongoid/user.rb +19 -22
- data/test/rails_app/app/mongoid/user_on_engine.rb +39 -0
- data/test/rails_app/app/mongoid/user_on_main_app.rb +39 -0
- data/test/rails_app/app/mongoid/user_without_email.rb +33 -0
- data/test/rails_app/app/views/admins/sessions/new.html.erb +1 -1
- data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -1
- data/test/rails_app/app/views/home/index.html.erb +1 -1
- data/test/rails_app/app/views/home/join.html.erb +1 -1
- data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -1
- data/test/rails_app/app/views/layouts/application.html.erb +1 -1
- data/test/rails_app/app/views/users/edit_form.html.erb +1 -0
- 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 +4 -5
- data/test/rails_app/config/boot.rb +9 -3
- data/test/rails_app/config/environment.rb +2 -2
- data/test/rails_app/config/environments/development.rb +19 -7
- data/test/rails_app/config/environments/production.rb +68 -17
- data/test/rails_app/config/environments/test.rb +24 -16
- data/test/rails_app/config/initializers/devise.rb +22 -20
- 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 +71 -46
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +9 -12
- data/test/rails_app/db/schema.rb +21 -18
- data/test/rails_app/lib/shared_admin.rb +7 -4
- data/test/rails_app/lib/shared_user.rb +6 -3
- data/test/rails_app/lib/shared_user_without_email.rb +26 -0
- data/test/rails_app/lib/shared_user_without_omniauth.rb +13 -0
- data/test/rails_test.rb +9 -0
- data/test/routes_test.rb +94 -78
- data/test/support/action_controller/record_identifier.rb +10 -0
- data/test/support/assertions.rb +2 -3
- data/test/support/helpers.rb +18 -32
- data/test/support/integration.rb +17 -16
- data/test/support/locale/en.yml +4 -0
- data/test/support/mongoid.yml +6 -0
- data/test/test_helper.rb +8 -1
- data/test/test_helpers_test.rb +64 -20
- data/test/test_models.rb +33 -0
- data/test/time_helpers.rb +137 -0
- metadata +172 -51
- data/app/views/devise/_links.erb +0 -3
- data/gemfiles/Gemfile.rails-3.1.x +0 -35
- data/gemfiles/Gemfile.rails-3.1.x.lock +0 -167
- data/lib/devise/models/token_authenticatable.rb +0 -77
- data/lib/devise/strategies/token_authenticatable.rb +0 -56
- data/test/indifferent_hash.rb +0 -33
- data/test/integration/token_authenticatable_test.rb +0 -161
- data/test/models/token_authenticatable_test.rb +0 -55
- data/test/rails_app/script/rails +0 -10
data/app/views/devise/_links.erb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
gem "devise", :path => ".."
|
4
|
-
|
5
|
-
gem "rails", "~> 3.1.0"
|
6
|
-
gem "omniauth", "~> 1.0.0"
|
7
|
-
gem "omniauth-oauth2", "~> 1.0.0"
|
8
|
-
gem "rdoc"
|
9
|
-
|
10
|
-
group :test do
|
11
|
-
gem "omniauth-facebook"
|
12
|
-
gem "omniauth-openid", "~> 1.0.1"
|
13
|
-
gem "webrat", "0.7.2", :require => false
|
14
|
-
gem "mocha", :require => false
|
15
|
-
|
16
|
-
platforms :mri_18 do
|
17
|
-
gem "ruby-debug", ">= 0.10.3"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
platforms :jruby do
|
22
|
-
gem "activerecord-jdbc-adapter"
|
23
|
-
gem "activerecord-jdbcsqlite3-adapter"
|
24
|
-
gem "jruby-openssl"
|
25
|
-
end
|
26
|
-
|
27
|
-
platforms :ruby do
|
28
|
-
gem "sqlite3"
|
29
|
-
|
30
|
-
group :mongoid do
|
31
|
-
gem "mongo", "~> 1.3.0"
|
32
|
-
gem "mongoid", "~> 2.0"
|
33
|
-
gem "bson_ext", "~> 1.3.0"
|
34
|
-
end
|
35
|
-
end
|
@@ -1,167 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
devise (2.1.0.rc2)
|
5
|
-
bcrypt-ruby (~> 3.0)
|
6
|
-
orm_adapter (~> 0.0.7)
|
7
|
-
railties (~> 3.1)
|
8
|
-
warden (~> 1.1.1)
|
9
|
-
|
10
|
-
GEM
|
11
|
-
remote: http://rubygems.org/
|
12
|
-
specs:
|
13
|
-
actionmailer (3.1.4)
|
14
|
-
actionpack (= 3.1.4)
|
15
|
-
mail (~> 2.3.0)
|
16
|
-
actionpack (3.1.4)
|
17
|
-
activemodel (= 3.1.4)
|
18
|
-
activesupport (= 3.1.4)
|
19
|
-
builder (~> 3.0.0)
|
20
|
-
erubis (~> 2.7.0)
|
21
|
-
i18n (~> 0.6)
|
22
|
-
rack (~> 1.3.6)
|
23
|
-
rack-cache (~> 1.1)
|
24
|
-
rack-mount (~> 0.8.2)
|
25
|
-
rack-test (~> 0.6.1)
|
26
|
-
sprockets (~> 2.0.3)
|
27
|
-
activemodel (3.1.4)
|
28
|
-
activesupport (= 3.1.4)
|
29
|
-
builder (~> 3.0.0)
|
30
|
-
i18n (~> 0.6)
|
31
|
-
activerecord (3.1.4)
|
32
|
-
activemodel (= 3.1.4)
|
33
|
-
activesupport (= 3.1.4)
|
34
|
-
arel (~> 2.2.3)
|
35
|
-
tzinfo (~> 0.3.29)
|
36
|
-
activeresource (3.1.4)
|
37
|
-
activemodel (= 3.1.4)
|
38
|
-
activesupport (= 3.1.4)
|
39
|
-
activesupport (3.1.4)
|
40
|
-
multi_json (~> 1.0)
|
41
|
-
addressable (2.2.7)
|
42
|
-
arel (2.2.3)
|
43
|
-
bcrypt-ruby (3.0.1)
|
44
|
-
bson (1.5.2)
|
45
|
-
bson_ext (1.3.1)
|
46
|
-
builder (3.0.0)
|
47
|
-
columnize (0.3.6)
|
48
|
-
erubis (2.7.0)
|
49
|
-
faraday (0.7.6)
|
50
|
-
addressable (~> 2.2)
|
51
|
-
multipart-post (~> 1.1)
|
52
|
-
rack (~> 1.1)
|
53
|
-
hashie (1.2.0)
|
54
|
-
hike (1.2.1)
|
55
|
-
i18n (0.6.0)
|
56
|
-
json (1.7.0)
|
57
|
-
linecache (0.46)
|
58
|
-
rbx-require-relative (> 0.0.4)
|
59
|
-
mail (2.3.3)
|
60
|
-
i18n (>= 0.4.0)
|
61
|
-
mime-types (~> 1.16)
|
62
|
-
treetop (~> 1.4.8)
|
63
|
-
metaclass (0.0.1)
|
64
|
-
mime-types (1.18)
|
65
|
-
mocha (0.10.4)
|
66
|
-
metaclass (~> 0.0.1)
|
67
|
-
mongo (1.3.1)
|
68
|
-
bson (>= 1.3.1)
|
69
|
-
mongoid (2.4.4)
|
70
|
-
activemodel (~> 3.1)
|
71
|
-
mongo (~> 1.3)
|
72
|
-
tzinfo (~> 0.3.22)
|
73
|
-
multi_json (1.3.4)
|
74
|
-
multipart-post (1.1.5)
|
75
|
-
nokogiri (1.5.0)
|
76
|
-
oauth2 (0.5.2)
|
77
|
-
faraday (~> 0.7)
|
78
|
-
multi_json (~> 1.0)
|
79
|
-
omniauth (1.0.2)
|
80
|
-
hashie (~> 1.2)
|
81
|
-
rack
|
82
|
-
omniauth-facebook (1.2.0)
|
83
|
-
omniauth-oauth2 (~> 1.0.0)
|
84
|
-
omniauth-oauth2 (1.0.0)
|
85
|
-
oauth2 (~> 0.5.0)
|
86
|
-
omniauth (~> 1.0)
|
87
|
-
omniauth-openid (1.0.1)
|
88
|
-
omniauth (~> 1.0)
|
89
|
-
rack-openid (~> 1.3.1)
|
90
|
-
orm_adapter (0.0.7)
|
91
|
-
polyglot (0.3.3)
|
92
|
-
rack (1.3.6)
|
93
|
-
rack-cache (1.2)
|
94
|
-
rack (>= 0.4)
|
95
|
-
rack-mount (0.8.3)
|
96
|
-
rack (>= 1.0.0)
|
97
|
-
rack-openid (1.3.1)
|
98
|
-
rack (>= 1.1.0)
|
99
|
-
ruby-openid (>= 2.1.8)
|
100
|
-
rack-ssl (1.3.2)
|
101
|
-
rack
|
102
|
-
rack-test (0.6.1)
|
103
|
-
rack (>= 1.0)
|
104
|
-
rails (3.1.4)
|
105
|
-
actionmailer (= 3.1.4)
|
106
|
-
actionpack (= 3.1.4)
|
107
|
-
activerecord (= 3.1.4)
|
108
|
-
activeresource (= 3.1.4)
|
109
|
-
activesupport (= 3.1.4)
|
110
|
-
bundler (~> 1.0)
|
111
|
-
railties (= 3.1.4)
|
112
|
-
railties (3.1.4)
|
113
|
-
actionpack (= 3.1.4)
|
114
|
-
activesupport (= 3.1.4)
|
115
|
-
rack-ssl (~> 1.3.2)
|
116
|
-
rake (>= 0.8.7)
|
117
|
-
rdoc (~> 3.4)
|
118
|
-
thor (~> 0.14.6)
|
119
|
-
rake (0.9.2.2)
|
120
|
-
rbx-require-relative (0.0.5)
|
121
|
-
rdoc (3.12)
|
122
|
-
json (~> 1.4)
|
123
|
-
ruby-debug (0.10.4)
|
124
|
-
columnize (>= 0.1)
|
125
|
-
ruby-debug-base (~> 0.10.4.0)
|
126
|
-
ruby-debug-base (0.10.4)
|
127
|
-
linecache (>= 0.3)
|
128
|
-
ruby-openid (2.1.8)
|
129
|
-
sprockets (2.0.4)
|
130
|
-
hike (~> 1.2)
|
131
|
-
rack (~> 1.0)
|
132
|
-
tilt (~> 1.1, != 1.3.0)
|
133
|
-
sqlite3 (1.3.5)
|
134
|
-
thor (0.14.6)
|
135
|
-
tilt (1.3.3)
|
136
|
-
treetop (1.4.10)
|
137
|
-
polyglot
|
138
|
-
polyglot (>= 0.3.1)
|
139
|
-
tzinfo (0.3.33)
|
140
|
-
warden (1.1.1)
|
141
|
-
rack (>= 1.0)
|
142
|
-
webrat (0.7.2)
|
143
|
-
nokogiri (>= 1.2.0)
|
144
|
-
rack (>= 1.0)
|
145
|
-
rack-test (>= 0.5.3)
|
146
|
-
|
147
|
-
PLATFORMS
|
148
|
-
ruby
|
149
|
-
|
150
|
-
DEPENDENCIES
|
151
|
-
activerecord-jdbc-adapter
|
152
|
-
activerecord-jdbcsqlite3-adapter
|
153
|
-
bson_ext (~> 1.3.0)
|
154
|
-
devise!
|
155
|
-
jruby-openssl
|
156
|
-
mocha
|
157
|
-
mongo (~> 1.3.0)
|
158
|
-
mongoid (~> 2.0)
|
159
|
-
omniauth (~> 1.0.0)
|
160
|
-
omniauth-facebook
|
161
|
-
omniauth-oauth2 (~> 1.0.0)
|
162
|
-
omniauth-openid (~> 1.0.1)
|
163
|
-
rails (~> 3.1.0)
|
164
|
-
rdoc
|
165
|
-
ruby-debug (>= 0.10.3)
|
166
|
-
sqlite3
|
167
|
-
webrat (= 0.7.2)
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'devise/strategies/token_authenticatable'
|
2
|
-
|
3
|
-
module Devise
|
4
|
-
module Models
|
5
|
-
# The TokenAuthenticatable module is responsible for generating an authentication token and
|
6
|
-
# validating the authenticity of the same while signing in.
|
7
|
-
#
|
8
|
-
# This module only provides a few helpers to help you manage the token, but it is up to you
|
9
|
-
# to choose how to use it. For example, if you want to have a new token every time the user
|
10
|
-
# saves his account, you can do the following:
|
11
|
-
#
|
12
|
-
# before_save :reset_authentication_token
|
13
|
-
#
|
14
|
-
# On the other hand, if you want to generate token unless one exists, you should use instead:
|
15
|
-
#
|
16
|
-
# before_save :ensure_authentication_token
|
17
|
-
#
|
18
|
-
# If you want to delete the token after it is used, you can do so in the
|
19
|
-
# after_token_authentication callback.
|
20
|
-
#
|
21
|
-
# == Options
|
22
|
-
#
|
23
|
-
# TokenAuthenticatable adds the following options to devise_for:
|
24
|
-
#
|
25
|
-
# * +token_authentication_key+: Defines name of the authentication token params key. E.g. /users/sign_in?some_key=...
|
26
|
-
#
|
27
|
-
module TokenAuthenticatable
|
28
|
-
extend ActiveSupport::Concern
|
29
|
-
|
30
|
-
def self.required_fields(klass)
|
31
|
-
[:authentication_token]
|
32
|
-
end
|
33
|
-
|
34
|
-
# Generate new authentication token (a.k.a. "single access token").
|
35
|
-
def reset_authentication_token
|
36
|
-
self.authentication_token = self.class.authentication_token
|
37
|
-
end
|
38
|
-
|
39
|
-
# Generate new authentication token and save the record.
|
40
|
-
def reset_authentication_token!
|
41
|
-
reset_authentication_token
|
42
|
-
save(:validate => false)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Generate authentication token unless already exists.
|
46
|
-
def ensure_authentication_token
|
47
|
-
reset_authentication_token if authentication_token.blank?
|
48
|
-
end
|
49
|
-
|
50
|
-
# Generate authentication token unless already exists and save the record.
|
51
|
-
def ensure_authentication_token!
|
52
|
-
reset_authentication_token! if authentication_token.blank?
|
53
|
-
end
|
54
|
-
|
55
|
-
# Hook called after token authentication.
|
56
|
-
def after_token_authentication
|
57
|
-
end
|
58
|
-
|
59
|
-
def expire_auth_token_on_timeout
|
60
|
-
self.class.expire_auth_token_on_timeout
|
61
|
-
end
|
62
|
-
|
63
|
-
module ClassMethods
|
64
|
-
def find_for_token_authentication(conditions)
|
65
|
-
find_for_authentication(:authentication_token => conditions[token_authentication_key])
|
66
|
-
end
|
67
|
-
|
68
|
-
# Generate a token checking if one does not already exist in the database.
|
69
|
-
def authentication_token
|
70
|
-
generate_token(:authentication_token)
|
71
|
-
end
|
72
|
-
|
73
|
-
Devise::Models.config(self, :token_authentication_key, :expire_auth_token_on_timeout)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'devise/strategies/base'
|
2
|
-
|
3
|
-
module Devise
|
4
|
-
module Strategies
|
5
|
-
# Strategy for signing in a user, based on a authenticatable token. This works for both params
|
6
|
-
# and http. For the former, all you need to do is to pass the params in the URL:
|
7
|
-
#
|
8
|
-
# http://myapp.example.com/?user_token=SECRET
|
9
|
-
#
|
10
|
-
# For HTTP, you can pass the token as username and blank password. Since some clients may require
|
11
|
-
# a password, you can pass "X" as password and it will simply be ignored.
|
12
|
-
class TokenAuthenticatable < Authenticatable
|
13
|
-
def store?
|
14
|
-
super && !mapping.to.skip_session_storage.include?(:token_auth)
|
15
|
-
end
|
16
|
-
|
17
|
-
def authenticate!
|
18
|
-
resource = mapping.to.find_for_token_authentication(authentication_hash)
|
19
|
-
return fail(:invalid_token) unless resource
|
20
|
-
|
21
|
-
if validate(resource)
|
22
|
-
resource.after_token_authentication
|
23
|
-
success!(resource)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
# Token Authenticatable can be authenticated with params in any controller and any verb.
|
30
|
-
def valid_params_request?
|
31
|
-
true
|
32
|
-
end
|
33
|
-
|
34
|
-
# Do not use remember_me behavior with token.
|
35
|
-
def remember_me?
|
36
|
-
false
|
37
|
-
end
|
38
|
-
|
39
|
-
# Try both scoped and non scoped keys.
|
40
|
-
def params_auth_hash
|
41
|
-
if params[scope].kind_of?(Hash) && params[scope].has_key?(authentication_keys.first)
|
42
|
-
params[scope]
|
43
|
-
else
|
44
|
-
params
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# Overwrite authentication keys to use token_authentication_key.
|
49
|
-
def authentication_keys
|
50
|
-
@authentication_keys ||= [mapping.to.token_authentication_key]
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
Warden::Strategies.add(:token_authenticatable, Devise::Strategies::TokenAuthenticatable)
|
data/test/indifferent_hash.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class IndifferentHashTest < ActiveSupport::TestCase
|
4
|
-
setup do
|
5
|
-
@hash = Devise::IndifferentHash.new
|
6
|
-
end
|
7
|
-
|
8
|
-
test "it overwrites getter and setter" do
|
9
|
-
@hash[:foo] = "bar"
|
10
|
-
assert_equal "bar", @hash["foo"]
|
11
|
-
assert_equal "bar", @hash[:foo]
|
12
|
-
|
13
|
-
@hash["foo"] = "baz"
|
14
|
-
assert_equal "baz", @hash["foo"]
|
15
|
-
assert_equal "baz", @hash[:foo]
|
16
|
-
end
|
17
|
-
|
18
|
-
test "it overwrites update" do
|
19
|
-
@hash.update :foo => "bar"
|
20
|
-
assert_equal "bar", @hash["foo"]
|
21
|
-
assert_equal "bar", @hash[:foo]
|
22
|
-
|
23
|
-
@hash.update "foo" => "baz"
|
24
|
-
assert_equal "baz", @hash["foo"]
|
25
|
-
assert_equal "baz", @hash[:foo]
|
26
|
-
end
|
27
|
-
|
28
|
-
test "it returns a Hash on to_hash" do
|
29
|
-
@hash[:foo] = "bar"
|
30
|
-
assert_equal Hash["foo", "bar"], @hash.to_hash
|
31
|
-
assert_kind_of Hash, @hash.to_hash
|
32
|
-
end
|
33
|
-
end if defined?(Devise::IndifferentHash)
|
@@ -1,161 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class TokenAuthenticationTest < ActionController::IntegrationTest
|
4
|
-
|
5
|
-
test 'authenticate with valid authentication token key and value through params' do
|
6
|
-
swap Devise, :token_authentication_key => :secret_token do
|
7
|
-
sign_in_as_new_user_with_token
|
8
|
-
|
9
|
-
assert_response :success
|
10
|
-
assert_current_url "/users?secret_token=#{VALID_AUTHENTICATION_TOKEN}"
|
11
|
-
assert_contain 'Welcome'
|
12
|
-
assert warden.authenticated?(:user)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
test 'authenticate with valid authentication token key and value through params, when params with the same key as scope exist' do
|
17
|
-
swap Devise, :token_authentication_key => :secret_token do
|
18
|
-
user = create_user_with_authentication_token
|
19
|
-
post exhibit_user_path(user), Devise.token_authentication_key => user.authentication_token, :user => { :some => "data" }
|
20
|
-
|
21
|
-
assert_response :success
|
22
|
-
assert_contain 'User is authenticated'
|
23
|
-
assert warden.authenticated?(:user)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
test 'authenticate with valid authentication token key but does not store if stateless' do
|
28
|
-
swap Devise, :token_authentication_key => :secret_token, :skip_session_storage => [:token_auth] do
|
29
|
-
sign_in_as_new_user_with_token
|
30
|
-
assert warden.authenticated?(:user)
|
31
|
-
|
32
|
-
get users_path
|
33
|
-
assert_redirected_to new_user_session_path
|
34
|
-
assert_not warden.authenticated?(:user)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
test 'authenticate with valid authentication token key and value through http' do
|
39
|
-
swap Devise, :token_authentication_key => :secret_token do
|
40
|
-
sign_in_as_new_user_with_token(:http_auth => true)
|
41
|
-
|
42
|
-
assert_response :success
|
43
|
-
assert_match '<email>user@test.com</email>', response.body
|
44
|
-
assert warden.authenticated?(:user)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
test 'does authenticate with valid authentication token key and value through params if not configured' do
|
49
|
-
swap Devise, :token_authentication_key => :secret_token, :params_authenticatable => [:database] do
|
50
|
-
sign_in_as_new_user_with_token
|
51
|
-
|
52
|
-
assert_contain 'You need to sign in or sign up before continuing'
|
53
|
-
assert_contain 'Sign in'
|
54
|
-
assert_not warden.authenticated?(:user)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
test 'does authenticate with valid authentication token key and value through http if not configured' do
|
59
|
-
swap Devise, :token_authentication_key => :secret_token, :http_authenticatable => [:database] do
|
60
|
-
sign_in_as_new_user_with_token(:http_auth => true)
|
61
|
-
|
62
|
-
assert_response 401
|
63
|
-
assert_contain 'Invalid email or password.'
|
64
|
-
assert_not warden.authenticated?(:user)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
test 'does not authenticate with improper authentication token key' do
|
69
|
-
swap Devise, :token_authentication_key => :donald_duck_token do
|
70
|
-
sign_in_as_new_user_with_token(:auth_token_key => :secret_token)
|
71
|
-
assert_equal new_user_session_path, @request.path
|
72
|
-
|
73
|
-
assert_contain 'You need to sign in or sign up before continuing'
|
74
|
-
assert_contain 'Sign in'
|
75
|
-
assert_not warden.authenticated?(:user)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
test 'does not authenticate with improper authentication token value' do
|
80
|
-
store_translations :en, :devise => {:failure => {:invalid_token => 'LOL, that was not a single character correct.'}} do
|
81
|
-
sign_in_as_new_user_with_token(:auth_token => '*** INVALID TOKEN ***')
|
82
|
-
assert_equal new_user_session_path, @request.path
|
83
|
-
|
84
|
-
assert_contain 'LOL, that was not a single character correct.'
|
85
|
-
assert_contain 'Sign in'
|
86
|
-
assert_not warden.authenticated?(:user)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
test 'authenticate with valid authentication token key and do not store if stateless and timeoutable are enabled' do
|
91
|
-
swap Devise, :token_authentication_key => :secret_token, :skip_session_storage => [:token_auth], :timeout_in => (0.1).second do
|
92
|
-
user = sign_in_as_new_user_with_token
|
93
|
-
assert warden.authenticated?(:user)
|
94
|
-
|
95
|
-
# Expiring does not work because we are setting the session value when accessing it
|
96
|
-
sleep 0.3
|
97
|
-
|
98
|
-
get_users_path_as_existing_user(user)
|
99
|
-
assert warden.authenticated?(:user)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
test 'should reset token and not authenticate when expire_auth_token_on_timeout is set to true, timeoutable is enabled and we have a timed out session' do
|
104
|
-
swap Devise, :token_authentication_key => :secret_token, :expire_auth_token_on_timeout => true, :timeout_in => (-1).minute do
|
105
|
-
user = sign_in_as_new_user_with_token
|
106
|
-
assert warden.authenticated?(:user)
|
107
|
-
token = user.authentication_token
|
108
|
-
|
109
|
-
get_users_path_as_existing_user(user)
|
110
|
-
assert_not warden.authenticated?(:user)
|
111
|
-
user.reload
|
112
|
-
assert_not_equal token, user.authentication_token
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
test 'should not be subject to injection' do
|
117
|
-
swap Devise, :token_authentication_key => :secret_token do
|
118
|
-
user1 = create_user_with_authentication_token()
|
119
|
-
|
120
|
-
# Clean up user cache
|
121
|
-
@user = nil
|
122
|
-
|
123
|
-
user2 = create_user_with_authentication_token(:email => "another@test.com")
|
124
|
-
user2.update_attribute(:authentication_token, "ANOTHERTOKEN")
|
125
|
-
|
126
|
-
assert_not_equal user1, user2
|
127
|
-
visit users_path(Devise.token_authentication_key.to_s + '[$ne]' => user1.authentication_token)
|
128
|
-
assert_nil warden.user(:user)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
private
|
133
|
-
|
134
|
-
def sign_in_as_new_user_with_token(options = {})
|
135
|
-
user = options.delete(:user) || create_user_with_authentication_token(options)
|
136
|
-
|
137
|
-
options[:auth_token_key] ||= Devise.token_authentication_key
|
138
|
-
options[:auth_token] ||= user.authentication_token
|
139
|
-
|
140
|
-
if options[:http_auth]
|
141
|
-
header = "Basic #{Base64.encode64("#{VALID_AUTHENTICATION_TOKEN}:X")}"
|
142
|
-
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => header
|
143
|
-
else
|
144
|
-
visit users_path(options[:auth_token_key].to_sym => options[:auth_token])
|
145
|
-
end
|
146
|
-
|
147
|
-
user
|
148
|
-
end
|
149
|
-
|
150
|
-
def create_user_with_authentication_token(options={})
|
151
|
-
user = create_user(options)
|
152
|
-
user.authentication_token = VALID_AUTHENTICATION_TOKEN
|
153
|
-
user.save
|
154
|
-
user
|
155
|
-
end
|
156
|
-
|
157
|
-
def get_users_path_as_existing_user(user)
|
158
|
-
sign_in_as_new_user_with_token(:user => user)
|
159
|
-
end
|
160
|
-
|
161
|
-
end
|