devise 3.2.4 → 4.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +259 -994
- data/MIT-LICENSE +1 -1
- data/README.md +336 -99
- data/app/controllers/devise/confirmations_controller.rb +9 -3
- data/app/controllers/devise/omniauth_callbacks_controller.rb +12 -6
- data/app/controllers/devise/passwords_controller.rb +19 -6
- data/app/controllers/devise/registrations_controller.rb +55 -22
- data/app/controllers/devise/sessions_controller.rb +44 -14
- data/app/controllers/devise/unlocks_controller.rb +7 -2
- data/app/controllers/devise_controller.rb +65 -29
- data/app/helpers/devise_helper.rb +12 -19
- data/app/mailers/devise/mailer.rb +10 -0
- data/app/views/devise/confirmations/new.html.erb +8 -4
- data/app/views/devise/mailer/email_changed.html.erb +7 -0
- data/app/views/devise/mailer/password_change.html.erb +3 -0
- 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 +27 -13
- data/app/views/devise/registrations/new.html.erb +19 -8
- data/app/views/devise/sessions/new.html.erb +18 -9
- data/app/views/devise/shared/_error_messages.html.erb +15 -0
- data/app/views/devise/shared/{_links.erb → _links.html.erb} +9 -9
- data/app/views/devise/unlocks/new.html.erb +8 -4
- data/config/locales/en.yml +22 -16
- data/lib/devise/controllers/helpers.rb +109 -29
- data/lib/devise/controllers/rememberable.rb +12 -3
- data/lib/devise/controllers/scoped_views.rb +2 -0
- data/lib/devise/controllers/sign_in_out.rb +36 -20
- data/lib/devise/controllers/store_location.rb +31 -5
- data/lib/devise/controllers/url_helpers.rb +9 -7
- data/lib/devise/delegator.rb +2 -0
- data/lib/devise/encryptor.rb +24 -0
- data/lib/devise/failure_app.rb +116 -36
- data/lib/devise/hooks/activatable.rb +5 -4
- data/lib/devise/hooks/csrf_cleaner.rb +5 -1
- data/lib/devise/hooks/forgetable.rb +2 -0
- data/lib/devise/hooks/lockable.rb +6 -1
- data/lib/devise/hooks/proxy.rb +3 -1
- data/lib/devise/hooks/rememberable.rb +2 -0
- data/lib/devise/hooks/timeoutable.rb +15 -8
- data/lib/devise/hooks/trackable.rb +2 -0
- data/lib/devise/mailers/helpers.rb +7 -4
- data/lib/devise/mapping.rb +8 -2
- data/lib/devise/models/authenticatable.rb +76 -51
- data/lib/devise/models/confirmable.rb +129 -34
- data/lib/devise/models/database_authenticatable.rb +107 -30
- data/lib/devise/models/lockable.rb +19 -9
- data/lib/devise/models/omniauthable.rb +2 -0
- data/lib/devise/models/recoverable.rb +62 -26
- data/lib/devise/models/registerable.rb +4 -0
- data/lib/devise/models/rememberable.rb +58 -29
- data/lib/devise/models/timeoutable.rb +2 -6
- data/lib/devise/models/trackable.rb +20 -4
- data/lib/devise/models/validatable.rb +12 -5
- data/lib/devise/models.rb +3 -1
- data/lib/devise/modules.rb +2 -0
- data/lib/devise/omniauth/config.rb +2 -0
- data/lib/devise/omniauth/url_helpers.rb +14 -5
- data/lib/devise/omniauth.rb +2 -0
- data/lib/devise/orm/active_record.rb +5 -1
- data/lib/devise/orm/mongoid.rb +6 -2
- data/lib/devise/parameter_filter.rb +4 -0
- data/lib/devise/parameter_sanitizer.rb +139 -65
- data/lib/devise/rails/routes.rb +80 -61
- data/lib/devise/rails/warden_compat.rb +3 -10
- data/lib/devise/rails.rb +8 -17
- data/lib/devise/secret_key_finder.rb +27 -0
- data/lib/devise/strategies/authenticatable.rb +18 -7
- data/lib/devise/strategies/base.rb +2 -0
- data/lib/devise/strategies/database_authenticatable.rb +13 -5
- data/lib/devise/strategies/rememberable.rb +15 -3
- data/lib/devise/test/controller_helpers.rb +165 -0
- data/lib/devise/test/integration_helpers.rb +63 -0
- data/lib/devise/test_helpers.rb +7 -124
- data/lib/devise/time_inflector.rb +2 -0
- data/lib/devise/token_generator.rb +3 -41
- data/lib/devise/version.rb +3 -1
- data/lib/devise.rb +106 -79
- data/lib/generators/active_record/devise_generator.rb +44 -7
- data/lib/generators/active_record/templates/migration.rb +5 -3
- data/lib/generators/active_record/templates/migration_existing.rb +5 -3
- data/lib/generators/devise/controllers_generator.rb +46 -0
- data/lib/generators/devise/devise_generator.rb +4 -2
- data/lib/generators/devise/install_generator.rb +17 -0
- data/lib/generators/devise/orm_helpers.rb +10 -21
- data/lib/generators/devise/views_generator.rb +21 -11
- data/lib/generators/mongoid/devise_generator.rb +7 -5
- data/lib/generators/templates/README +2 -9
- data/lib/generators/templates/controllers/README +14 -0
- data/lib/generators/templates/controllers/confirmations_controller.rb +30 -0
- data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +30 -0
- data/lib/generators/templates/controllers/passwords_controller.rb +34 -0
- data/lib/generators/templates/controllers/registrations_controller.rb +62 -0
- data/lib/generators/templates/controllers/sessions_controller.rb +27 -0
- data/lib/generators/templates/controllers/unlocks_controller.rb +30 -0
- data/lib/generators/templates/devise.rb +69 -30
- data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
- data/lib/generators/templates/markerb/email_changed.markerb +7 -0
- 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 +1 -1
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +5 -1
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +10 -2
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +4 -1
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +11 -3
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +11 -3
- data/lib/generators/templates/simple_form_for/sessions/new.html.erb +9 -4
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +4 -1
- metadata +31 -259
- data/.gitignore +0 -11
- data/.travis.yml +0 -28
- data/.yardopts +0 -9
- data/CONTRIBUTING.md +0 -14
- data/Gemfile +0 -29
- data/Gemfile.lock +0 -160
- data/Rakefile +0 -35
- data/devise.gemspec +0 -27
- data/devise.png +0 -0
- data/gemfiles/Gemfile.rails-3.2-stable +0 -29
- data/gemfiles/Gemfile.rails-4.0-stable +0 -29
- data/gemfiles/Gemfile.rails-head +0 -29
- data/test/controllers/custom_strategy_test.rb +0 -62
- data/test/controllers/helpers_test.rb +0 -276
- data/test/controllers/internal_helpers_test.rb +0 -123
- data/test/controllers/passwords_controller_test.rb +0 -31
- data/test/controllers/sessions_controller_test.rb +0 -103
- data/test/controllers/url_helpers_test.rb +0 -59
- data/test/delegator_test.rb +0 -19
- data/test/devise_test.rb +0 -94
- data/test/failure_app_test.rb +0 -232
- data/test/generators/active_record_generator_test.rb +0 -103
- data/test/generators/devise_generator_test.rb +0 -39
- data/test/generators/install_generator_test.rb +0 -13
- data/test/generators/mongoid_generator_test.rb +0 -23
- data/test/generators/views_generator_test.rb +0 -96
- data/test/helpers/devise_helper_test.rb +0 -51
- data/test/integration/authenticatable_test.rb +0 -713
- data/test/integration/confirmable_test.rb +0 -284
- data/test/integration/database_authenticatable_test.rb +0 -84
- data/test/integration/http_authenticatable_test.rb +0 -105
- data/test/integration/lockable_test.rb +0 -239
- data/test/integration/omniauthable_test.rb +0 -133
- data/test/integration/recoverable_test.rb +0 -334
- data/test/integration/registerable_test.rb +0 -349
- data/test/integration/rememberable_test.rb +0 -167
- data/test/integration/timeoutable_test.rb +0 -183
- data/test/integration/trackable_test.rb +0 -92
- data/test/mailers/confirmation_instructions_test.rb +0 -115
- data/test/mailers/reset_password_instructions_test.rb +0 -96
- data/test/mailers/unlock_instructions_test.rb +0 -91
- data/test/mapping_test.rb +0 -127
- data/test/models/authenticatable_test.rb +0 -13
- data/test/models/confirmable_test.rb +0 -454
- data/test/models/database_authenticatable_test.rb +0 -249
- data/test/models/lockable_test.rb +0 -316
- data/test/models/omniauthable_test.rb +0 -7
- data/test/models/recoverable_test.rb +0 -184
- data/test/models/registerable_test.rb +0 -7
- data/test/models/rememberable_test.rb +0 -183
- data/test/models/serializable_test.rb +0 -49
- data/test/models/timeoutable_test.rb +0 -51
- data/test/models/trackable_test.rb +0 -13
- data/test/models/validatable_test.rb +0 -127
- data/test/models_test.rb +0 -144
- data/test/omniauth/config_test.rb +0 -57
- data/test/omniauth/url_helpers_test.rb +0 -54
- data/test/orm/active_record.rb +0 -10
- data/test/orm/mongoid.rb +0 -13
- data/test/parameter_sanitizer_test.rb +0 -81
- data/test/rails_app/Rakefile +0 -6
- data/test/rails_app/app/active_record/admin.rb +0 -6
- data/test/rails_app/app/active_record/shim.rb +0 -2
- data/test/rails_app/app/active_record/user.rb +0 -6
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +0 -6
- data/test/rails_app/app/controllers/admins_controller.rb +0 -11
- data/test/rails_app/app/controllers/application_controller.rb +0 -9
- data/test/rails_app/app/controllers/home_controller.rb +0 -25
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +0 -2
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +0 -2
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +0 -14
- data/test/rails_app/app/controllers/users_controller.rb +0 -31
- data/test/rails_app/app/helpers/application_helper.rb +0 -3
- data/test/rails_app/app/mailers/users/mailer.rb +0 -12
- data/test/rails_app/app/mongoid/admin.rb +0 -29
- data/test/rails_app/app/mongoid/shim.rb +0 -23
- data/test/rails_app/app/mongoid/user.rb +0 -39
- data/test/rails_app/app/views/admins/index.html.erb +0 -1
- data/test/rails_app/app/views/admins/sessions/new.html.erb +0 -2
- data/test/rails_app/app/views/home/admin_dashboard.html.erb +0 -1
- data/test/rails_app/app/views/home/index.html.erb +0 -1
- data/test/rails_app/app/views/home/join.html.erb +0 -1
- data/test/rails_app/app/views/home/private.html.erb +0 -1
- data/test/rails_app/app/views/home/user_dashboard.html.erb +0 -1
- data/test/rails_app/app/views/layouts/application.html.erb +0 -24
- data/test/rails_app/app/views/users/edit_form.html.erb +0 -1
- data/test/rails_app/app/views/users/index.html.erb +0 -1
- data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +0 -1
- data/test/rails_app/app/views/users/sessions/new.html.erb +0 -1
- data/test/rails_app/bin/bundle +0 -3
- data/test/rails_app/bin/rails +0 -4
- data/test/rails_app/bin/rake +0 -4
- data/test/rails_app/config/application.rb +0 -40
- data/test/rails_app/config/boot.rb +0 -14
- data/test/rails_app/config/database.yml +0 -18
- data/test/rails_app/config/environment.rb +0 -5
- data/test/rails_app/config/environments/development.rb +0 -30
- data/test/rails_app/config/environments/production.rb +0 -80
- data/test/rails_app/config/environments/test.rb +0 -36
- data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -7
- data/test/rails_app/config/initializers/devise.rb +0 -181
- data/test/rails_app/config/initializers/inflections.rb +0 -2
- data/test/rails_app/config/initializers/secret_token.rb +0 -8
- data/test/rails_app/config/initializers/session_store.rb +0 -1
- data/test/rails_app/config/routes.rb +0 -105
- data/test/rails_app/config.ru +0 -4
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -71
- data/test/rails_app/db/schema.rb +0 -55
- data/test/rails_app/lib/shared_admin.rb +0 -17
- data/test/rails_app/lib/shared_user.rb +0 -29
- data/test/rails_app/public/404.html +0 -26
- data/test/rails_app/public/422.html +0 -26
- data/test/rails_app/public/500.html +0 -26
- data/test/rails_app/public/favicon.ico +0 -0
- data/test/routes_test.rb +0 -262
- data/test/support/action_controller/record_identifier.rb +0 -10
- data/test/support/assertions.rb +0 -40
- data/test/support/helpers.rb +0 -70
- data/test/support/integration.rb +0 -92
- data/test/support/locale/en.yml +0 -8
- data/test/support/mongoid.yml +0 -6
- data/test/support/webrat/integrations/rails.rb +0 -24
- data/test/test_helper.rb +0 -27
- data/test/test_helpers_test.rb +0 -173
- data/test/test_models.rb +0 -33
data/Gemfile.lock
DELETED
@@ -1,160 +0,0 @@
|
|
1
|
-
GIT
|
2
|
-
remote: git://github.com/mongoid/mongoid.git
|
3
|
-
revision: 346a79a7d01aa194de80e649916239a18d38ce13
|
4
|
-
branch: master
|
5
|
-
specs:
|
6
|
-
mongoid (4.0.0)
|
7
|
-
activemodel (~> 4.0.0)
|
8
|
-
moped (~> 1.5)
|
9
|
-
origin (~> 1.0)
|
10
|
-
tzinfo (~> 0.3.22)
|
11
|
-
|
12
|
-
PATH
|
13
|
-
remote: .
|
14
|
-
specs:
|
15
|
-
devise (3.2.4)
|
16
|
-
bcrypt (~> 3.0)
|
17
|
-
orm_adapter (~> 0.1)
|
18
|
-
railties (>= 3.2.6, < 5)
|
19
|
-
thread_safe (~> 0.1)
|
20
|
-
warden (~> 1.2.3)
|
21
|
-
|
22
|
-
GEM
|
23
|
-
remote: https://rubygems.org/
|
24
|
-
specs:
|
25
|
-
actionmailer (4.0.0)
|
26
|
-
actionpack (= 4.0.0)
|
27
|
-
mail (~> 2.5.3)
|
28
|
-
actionpack (4.0.0)
|
29
|
-
activesupport (= 4.0.0)
|
30
|
-
builder (~> 3.1.0)
|
31
|
-
erubis (~> 2.7.0)
|
32
|
-
rack (~> 1.5.2)
|
33
|
-
rack-test (~> 0.6.2)
|
34
|
-
activemodel (4.0.0)
|
35
|
-
activesupport (= 4.0.0)
|
36
|
-
builder (~> 3.1.0)
|
37
|
-
activerecord (4.0.0)
|
38
|
-
activemodel (= 4.0.0)
|
39
|
-
activerecord-deprecated_finders (~> 1.0.2)
|
40
|
-
activesupport (= 4.0.0)
|
41
|
-
arel (~> 4.0.0)
|
42
|
-
activerecord-deprecated_finders (1.0.3)
|
43
|
-
activesupport (4.0.0)
|
44
|
-
i18n (~> 0.6, >= 0.6.4)
|
45
|
-
minitest (~> 4.2)
|
46
|
-
multi_json (~> 1.3)
|
47
|
-
thread_safe (~> 0.1)
|
48
|
-
tzinfo (~> 0.3.37)
|
49
|
-
arel (4.0.0)
|
50
|
-
atomic (1.1.12)
|
51
|
-
bcrypt (3.1.7)
|
52
|
-
builder (3.1.4)
|
53
|
-
erubis (2.7.0)
|
54
|
-
faraday (0.8.8)
|
55
|
-
multipart-post (~> 1.2.0)
|
56
|
-
hashie (1.2.0)
|
57
|
-
hike (1.2.3)
|
58
|
-
httpauth (0.2.0)
|
59
|
-
i18n (0.6.5)
|
60
|
-
json (1.8.0)
|
61
|
-
jwt (0.1.8)
|
62
|
-
multi_json (>= 1.5)
|
63
|
-
mail (2.5.4)
|
64
|
-
mime-types (~> 1.16)
|
65
|
-
treetop (~> 1.4.8)
|
66
|
-
metaclass (0.0.4)
|
67
|
-
mime-types (1.23)
|
68
|
-
minitest (4.7.5)
|
69
|
-
mocha (1.0.0)
|
70
|
-
metaclass (~> 0.0.1)
|
71
|
-
moped (1.5.1)
|
72
|
-
multi_json (1.7.9)
|
73
|
-
multipart-post (1.2.0)
|
74
|
-
nokogiri (1.5.9)
|
75
|
-
oauth2 (0.8.1)
|
76
|
-
faraday (~> 0.8)
|
77
|
-
httpauth (~> 0.1)
|
78
|
-
jwt (~> 0.1.4)
|
79
|
-
multi_json (~> 1.0)
|
80
|
-
rack (~> 1.2)
|
81
|
-
omniauth (1.0.3)
|
82
|
-
hashie (~> 1.2)
|
83
|
-
rack
|
84
|
-
omniauth-facebook (1.4.0)
|
85
|
-
omniauth-oauth2 (~> 1.0.2)
|
86
|
-
omniauth-oauth2 (1.0.3)
|
87
|
-
oauth2 (~> 0.8.0)
|
88
|
-
omniauth (~> 1.0)
|
89
|
-
omniauth-openid (1.0.1)
|
90
|
-
omniauth (~> 1.0)
|
91
|
-
rack-openid (~> 1.3.1)
|
92
|
-
origin (1.1.0)
|
93
|
-
orm_adapter (0.5.0)
|
94
|
-
polyglot (0.3.3)
|
95
|
-
rack (1.5.2)
|
96
|
-
rack-openid (1.3.1)
|
97
|
-
rack (>= 1.1.0)
|
98
|
-
ruby-openid (>= 2.1.8)
|
99
|
-
rack-test (0.6.2)
|
100
|
-
rack (>= 1.0)
|
101
|
-
rails (4.0.0)
|
102
|
-
actionmailer (= 4.0.0)
|
103
|
-
actionpack (= 4.0.0)
|
104
|
-
activerecord (= 4.0.0)
|
105
|
-
activesupport (= 4.0.0)
|
106
|
-
bundler (>= 1.3.0, < 2.0)
|
107
|
-
railties (= 4.0.0)
|
108
|
-
sprockets-rails (~> 2.0.0)
|
109
|
-
railties (4.0.0)
|
110
|
-
actionpack (= 4.0.0)
|
111
|
-
activesupport (= 4.0.0)
|
112
|
-
rake (>= 0.8.7)
|
113
|
-
thor (>= 0.18.1, < 2.0)
|
114
|
-
rake (10.1.0)
|
115
|
-
rdoc (4.0.1)
|
116
|
-
json (~> 1.4)
|
117
|
-
ruby-openid (2.2.3)
|
118
|
-
sprockets (2.10.0)
|
119
|
-
hike (~> 1.2)
|
120
|
-
multi_json (~> 1.0)
|
121
|
-
rack (~> 1.0)
|
122
|
-
tilt (~> 1.1, != 1.3.0)
|
123
|
-
sprockets-rails (2.0.0)
|
124
|
-
actionpack (>= 3.0)
|
125
|
-
activesupport (>= 3.0)
|
126
|
-
sprockets (~> 2.8)
|
127
|
-
sqlite3 (1.3.7)
|
128
|
-
thor (0.18.1)
|
129
|
-
thread_safe (0.1.2)
|
130
|
-
atomic
|
131
|
-
tilt (1.4.1)
|
132
|
-
treetop (1.4.14)
|
133
|
-
polyglot
|
134
|
-
polyglot (>= 0.3.1)
|
135
|
-
tzinfo (0.3.37)
|
136
|
-
warden (1.2.3)
|
137
|
-
rack (>= 1.0)
|
138
|
-
webrat (0.7.3)
|
139
|
-
nokogiri (>= 1.2.0)
|
140
|
-
rack (>= 1.0)
|
141
|
-
rack-test (>= 0.5.3)
|
142
|
-
|
143
|
-
PLATFORMS
|
144
|
-
ruby
|
145
|
-
|
146
|
-
DEPENDENCIES
|
147
|
-
activerecord-jdbc-adapter
|
148
|
-
activerecord-jdbcsqlite3-adapter
|
149
|
-
devise!
|
150
|
-
jruby-openssl
|
151
|
-
mocha (~> 1.0.0)
|
152
|
-
mongoid!
|
153
|
-
omniauth (~> 1.0.0)
|
154
|
-
omniauth-facebook
|
155
|
-
omniauth-oauth2 (~> 1.0.0)
|
156
|
-
omniauth-openid (~> 1.0.1)
|
157
|
-
rails (~> 4.0.0)
|
158
|
-
rdoc
|
159
|
-
sqlite3
|
160
|
-
webrat (= 0.7.3)
|
data/Rakefile
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require "bundler/gem_tasks"
|
3
|
-
require 'rake/testtask'
|
4
|
-
require 'rdoc/task'
|
5
|
-
|
6
|
-
desc 'Default: run tests for all ORMs.'
|
7
|
-
task default: :test
|
8
|
-
|
9
|
-
desc 'Run Devise tests for all ORMs.'
|
10
|
-
task :pre_commit do
|
11
|
-
Dir[File.join(File.dirname(__FILE__), 'test', 'orm', '*.rb')].each do |file|
|
12
|
-
orm = File.basename(file).split(".").first
|
13
|
-
# "Some day, my son, rake's inner wisdom will reveal itself. Until then,
|
14
|
-
# take this `system` -- may its brute force protect you well."
|
15
|
-
exit 1 unless system "rake test DEVISE_ORM=#{orm}"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
desc 'Run Devise unit tests.'
|
20
|
-
Rake::TestTask.new(:test) do |t|
|
21
|
-
t.libs << 'lib'
|
22
|
-
t.libs << 'test'
|
23
|
-
t.pattern = 'test/**/*_test.rb'
|
24
|
-
t.verbose = true
|
25
|
-
t.warning = false
|
26
|
-
end
|
27
|
-
|
28
|
-
desc 'Generate documentation for Devise.'
|
29
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
30
|
-
rdoc.rdoc_dir = 'rdoc'
|
31
|
-
rdoc.title = 'Devise'
|
32
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
33
|
-
rdoc.rdoc_files.include('README.md')
|
34
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
35
|
-
end
|
data/devise.gemspec
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "devise/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "devise"
|
7
|
-
s.version = Devise::VERSION.dup
|
8
|
-
s.platform = Gem::Platform::RUBY
|
9
|
-
s.licenses = ["MIT"]
|
10
|
-
s.summary = "Flexible authentication solution for Rails with Warden"
|
11
|
-
s.email = "contact@plataformatec.com.br"
|
12
|
-
s.homepage = "https://github.com/plataformatec/devise"
|
13
|
-
s.description = "Flexible authentication solution for Rails with Warden"
|
14
|
-
s.authors = ['José Valim', 'Carlos Antônio']
|
15
|
-
|
16
|
-
s.rubyforge_project = "devise"
|
17
|
-
|
18
|
-
s.files = `git ls-files`.split("\n")
|
19
|
-
s.test_files = `git ls-files -- test/*`.split("\n")
|
20
|
-
s.require_paths = ["lib"]
|
21
|
-
|
22
|
-
s.add_dependency("warden", "~> 1.2.3")
|
23
|
-
s.add_dependency("orm_adapter", "~> 0.1")
|
24
|
-
s.add_dependency("bcrypt", "~> 3.0")
|
25
|
-
s.add_dependency("thread_safe", "~> 0.1")
|
26
|
-
s.add_dependency("railties", ">= 3.2.6", "< 5")
|
27
|
-
end
|
data/devise.png
DELETED
Binary file
|
@@ -1,29 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gemspec path: '..'
|
4
|
-
|
5
|
-
gem "rails", github: 'rails/rails', branch: '3-2-stable'
|
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.3", require: false
|
14
|
-
gem "mocha", "~> 1.0.0", require: false
|
15
|
-
end
|
16
|
-
|
17
|
-
platforms :jruby do
|
18
|
-
gem "activerecord-jdbc-adapter"
|
19
|
-
gem "activerecord-jdbcsqlite3-adapter"
|
20
|
-
gem "jruby-openssl"
|
21
|
-
end
|
22
|
-
|
23
|
-
platforms :ruby do
|
24
|
-
gem "sqlite3"
|
25
|
-
end
|
26
|
-
|
27
|
-
group :mongoid do
|
28
|
-
gem "mongoid", "~> 3.0"
|
29
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gemspec path: '..'
|
4
|
-
|
5
|
-
gem "rails", github: 'rails/rails', branch: '4-0-stable'
|
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.3", require: false
|
14
|
-
gem "mocha", "~> 1.0.0", require: false
|
15
|
-
end
|
16
|
-
|
17
|
-
platforms :jruby do
|
18
|
-
gem "activerecord-jdbc-adapter"
|
19
|
-
gem "activerecord-jdbcsqlite3-adapter"
|
20
|
-
gem "jruby-openssl"
|
21
|
-
end
|
22
|
-
|
23
|
-
platforms :ruby do
|
24
|
-
gem "sqlite3"
|
25
|
-
end
|
26
|
-
|
27
|
-
group :mongoid do
|
28
|
-
gem "mongoid", github: "mongoid/mongoid", branch: "master"
|
29
|
-
end
|
data/gemfiles/Gemfile.rails-head
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gemspec path: '..'
|
4
|
-
|
5
|
-
gem "rails", github: 'rails/rails'
|
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.3", require: false
|
14
|
-
gem "mocha", "~> 1.0.0", require: false
|
15
|
-
end
|
16
|
-
|
17
|
-
platforms :jruby do
|
18
|
-
gem "activerecord-jdbc-adapter"
|
19
|
-
gem "activerecord-jdbcsqlite3-adapter"
|
20
|
-
gem "jruby-openssl"
|
21
|
-
end
|
22
|
-
|
23
|
-
platforms :ruby do
|
24
|
-
gem "sqlite3"
|
25
|
-
end
|
26
|
-
|
27
|
-
group :mongoid do
|
28
|
-
gem "mongoid", github: "mongoid/mongoid", branch: "master"
|
29
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'ostruct'
|
3
|
-
require 'warden/strategies/base'
|
4
|
-
require 'devise/test_helpers'
|
5
|
-
|
6
|
-
class CustomStrategyController < ActionController::Base
|
7
|
-
def new
|
8
|
-
warden.authenticate!(:custom_strategy)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
# These tests are to prove that a warden strategy can successfully
|
13
|
-
# return a custom response, including a specific status code and
|
14
|
-
# custom http response headers. This does work in production,
|
15
|
-
# however, at the time of writing this, the Devise test helpers do
|
16
|
-
# not recognise the custom response and proceed to calling the
|
17
|
-
# Failure App. This makes it impossible to write tests for a
|
18
|
-
# strategy that return a custom response with Devise.
|
19
|
-
class CustomStrategy < Warden::Strategies::Base
|
20
|
-
def authenticate!
|
21
|
-
custom_headers = { "X-FOO" => "BAR" }
|
22
|
-
response = Rack::Response.new("BAD REQUEST", 400, custom_headers)
|
23
|
-
custom! response.finish
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
class CustomStrategyTest < ActionController::TestCase
|
28
|
-
tests CustomStrategyController
|
29
|
-
|
30
|
-
include Devise::TestHelpers
|
31
|
-
|
32
|
-
setup do
|
33
|
-
Warden::Strategies.add(:custom_strategy, CustomStrategy)
|
34
|
-
end
|
35
|
-
|
36
|
-
teardown do
|
37
|
-
Warden::Strategies._strategies.delete(:custom_strategy)
|
38
|
-
end
|
39
|
-
|
40
|
-
test "custom strategy can return its own status code" do
|
41
|
-
ret = get :new
|
42
|
-
|
43
|
-
# check the returned rack array
|
44
|
-
assert ret.is_a?(Array)
|
45
|
-
assert_equal 400, ret.first
|
46
|
-
|
47
|
-
# check the saved response as well. This is purely so that the response is available to the testing framework
|
48
|
-
# for verification. In production, the above array would be delivered directly to Rack.
|
49
|
-
assert_response 400
|
50
|
-
end
|
51
|
-
|
52
|
-
test "custom strategy can return custom headers" do
|
53
|
-
ret = get :new
|
54
|
-
|
55
|
-
# check the returned rack array
|
56
|
-
assert ret.is_a?(Array)
|
57
|
-
assert_equal ret.third['X-FOO'], 'BAR'
|
58
|
-
|
59
|
-
# check the saved response headers as well.
|
60
|
-
assert_equal response.headers['X-FOO'], 'BAR'
|
61
|
-
end
|
62
|
-
end
|
@@ -1,276 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'ostruct'
|
3
|
-
|
4
|
-
class ControllerAuthenticatableTest < ActionController::TestCase
|
5
|
-
tests ApplicationController
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@mock_warden = OpenStruct.new
|
9
|
-
@controller.request.env['warden'] = @mock_warden
|
10
|
-
end
|
11
|
-
|
12
|
-
test 'provide access to warden instance' do
|
13
|
-
assert_equal @mock_warden, @controller.warden
|
14
|
-
end
|
15
|
-
|
16
|
-
test 'proxy signed_in?(scope) to authenticate?' do
|
17
|
-
@mock_warden.expects(:authenticate?).with(scope: :my_scope)
|
18
|
-
@controller.signed_in?(:my_scope)
|
19
|
-
end
|
20
|
-
|
21
|
-
test 'proxy signed_in?(nil) to authenticate?' do
|
22
|
-
Devise.mappings.keys.each do |scope| # :user, :admin, :manager
|
23
|
-
@mock_warden.expects(:authenticate?).with(scope: scope)
|
24
|
-
end
|
25
|
-
@controller.signed_in?
|
26
|
-
end
|
27
|
-
|
28
|
-
test 'proxy current_user to authenticate with user scope' do
|
29
|
-
@mock_warden.expects(:authenticate).with(scope: :user)
|
30
|
-
@controller.current_user
|
31
|
-
end
|
32
|
-
|
33
|
-
test 'proxy current_admin to authenticate with admin scope' do
|
34
|
-
@mock_warden.expects(:authenticate).with(scope: :admin)
|
35
|
-
@controller.current_admin
|
36
|
-
end
|
37
|
-
|
38
|
-
test 'proxy current_publisher_account to authenticate with namespaced publisher account scope' do
|
39
|
-
@mock_warden.expects(:authenticate).with(scope: :publisher_account)
|
40
|
-
@controller.current_publisher_account
|
41
|
-
end
|
42
|
-
|
43
|
-
test 'proxy authenticate_user! to authenticate with user scope' do
|
44
|
-
@mock_warden.expects(:authenticate!).with(scope: :user)
|
45
|
-
@controller.authenticate_user!
|
46
|
-
end
|
47
|
-
|
48
|
-
test 'proxy authenticate_user! options to authenticate with user scope' do
|
49
|
-
@mock_warden.expects(:authenticate!).with(scope: :user, recall: "foo")
|
50
|
-
@controller.authenticate_user!(recall: "foo")
|
51
|
-
end
|
52
|
-
|
53
|
-
test 'proxy authenticate_admin! to authenticate with admin scope' do
|
54
|
-
@mock_warden.expects(:authenticate!).with(scope: :admin)
|
55
|
-
@controller.authenticate_admin!
|
56
|
-
end
|
57
|
-
|
58
|
-
test 'proxy authenticate_publisher_account! to authenticate with namespaced publisher account scope' do
|
59
|
-
@mock_warden.expects(:authenticate!).with(scope: :publisher_account)
|
60
|
-
@controller.authenticate_publisher_account!
|
61
|
-
end
|
62
|
-
|
63
|
-
test 'proxy user_signed_in? to authenticate with user scope' do
|
64
|
-
@mock_warden.expects(:authenticate).with(scope: :user).returns("user")
|
65
|
-
assert @controller.user_signed_in?
|
66
|
-
end
|
67
|
-
|
68
|
-
test 'proxy admin_signed_in? to authenticatewith admin scope' do
|
69
|
-
@mock_warden.expects(:authenticate).with(scope: :admin)
|
70
|
-
assert_not @controller.admin_signed_in?
|
71
|
-
end
|
72
|
-
|
73
|
-
test 'proxy publisher_account_signed_in? to authenticate with namespaced publisher account scope' do
|
74
|
-
@mock_warden.expects(:authenticate).with(scope: :publisher_account)
|
75
|
-
@controller.publisher_account_signed_in?
|
76
|
-
end
|
77
|
-
|
78
|
-
test 'proxy user_session to session scope in warden' do
|
79
|
-
@mock_warden.expects(:authenticate).with(scope: :user).returns(true)
|
80
|
-
@mock_warden.expects(:session).with(:user).returns({})
|
81
|
-
@controller.user_session
|
82
|
-
end
|
83
|
-
|
84
|
-
test 'proxy admin_session to session scope in warden' do
|
85
|
-
@mock_warden.expects(:authenticate).with(scope: :admin).returns(true)
|
86
|
-
@mock_warden.expects(:session).with(:admin).returns({})
|
87
|
-
@controller.admin_session
|
88
|
-
end
|
89
|
-
|
90
|
-
test 'proxy publisher_account_session from namespaced scope to session scope in warden' do
|
91
|
-
@mock_warden.expects(:authenticate).with(scope: :publisher_account).returns(true)
|
92
|
-
@mock_warden.expects(:session).with(:publisher_account).returns({})
|
93
|
-
@controller.publisher_account_session
|
94
|
-
end
|
95
|
-
|
96
|
-
test 'sign in proxy to set_user on warden' do
|
97
|
-
user = User.new
|
98
|
-
@mock_warden.expects(:user).returns(nil)
|
99
|
-
@mock_warden.expects(:set_user).with(user, scope: :user).returns(true)
|
100
|
-
@controller.sign_in(:user, user)
|
101
|
-
end
|
102
|
-
|
103
|
-
test 'sign in accepts a resource as argument' do
|
104
|
-
user = User.new
|
105
|
-
@mock_warden.expects(:user).returns(nil)
|
106
|
-
@mock_warden.expects(:set_user).with(user, scope: :user).returns(true)
|
107
|
-
@controller.sign_in(user)
|
108
|
-
end
|
109
|
-
|
110
|
-
test 'does not sign in again if the user is already in' do
|
111
|
-
user = User.new
|
112
|
-
@mock_warden.expects(:user).returns(user)
|
113
|
-
@mock_warden.expects(:set_user).never
|
114
|
-
assert @controller.sign_in(user)
|
115
|
-
end
|
116
|
-
|
117
|
-
test 'sign in again when the user is already in only if force is given' do
|
118
|
-
user = User.new
|
119
|
-
@mock_warden.expects(:user).returns(user)
|
120
|
-
@mock_warden.expects(:set_user).with(user, scope: :user).returns(true)
|
121
|
-
@controller.sign_in(user, force: true)
|
122
|
-
end
|
123
|
-
|
124
|
-
test 'sign in accepts bypass as option' do
|
125
|
-
user = User.new
|
126
|
-
@mock_warden.expects(:session_serializer).returns(serializer = mock())
|
127
|
-
serializer.expects(:store).with(user, :user)
|
128
|
-
@controller.sign_in(user, bypass: true)
|
129
|
-
end
|
130
|
-
|
131
|
-
test 'sign out clears up any signed in user from all scopes' do
|
132
|
-
user = User.new
|
133
|
-
@mock_warden.expects(:user).times(Devise.mappings.size)
|
134
|
-
@mock_warden.expects(:logout).with().returns(true)
|
135
|
-
@controller.instance_variable_set(:@current_user, user)
|
136
|
-
@controller.instance_variable_set(:@current_admin, user)
|
137
|
-
@controller.sign_out
|
138
|
-
assert_equal nil, @controller.instance_variable_get(:@current_user)
|
139
|
-
assert_equal nil, @controller.instance_variable_get(:@current_admin)
|
140
|
-
end
|
141
|
-
|
142
|
-
test 'sign out logs out and clears up any signed in user by scope' do
|
143
|
-
user = User.new
|
144
|
-
@mock_warden.expects(:user).with(scope: :user, run_callbacks: false).returns(user)
|
145
|
-
@mock_warden.expects(:logout).with(:user).returns(true)
|
146
|
-
@mock_warden.expects(:clear_strategies_cache!).with(scope: :user).returns(true)
|
147
|
-
@controller.instance_variable_set(:@current_user, user)
|
148
|
-
@controller.sign_out(:user)
|
149
|
-
assert_equal nil, @controller.instance_variable_get(:@current_user)
|
150
|
-
end
|
151
|
-
|
152
|
-
test 'sign out accepts a resource as argument' do
|
153
|
-
@mock_warden.expects(:user).with(scope: :user, run_callbacks: false).returns(true)
|
154
|
-
@mock_warden.expects(:logout).with(:user).returns(true)
|
155
|
-
@mock_warden.expects(:clear_strategies_cache!).with(scope: :user).returns(true)
|
156
|
-
@controller.sign_out(User.new)
|
157
|
-
end
|
158
|
-
|
159
|
-
test 'sign out without args proxy to sign out all scopes' do
|
160
|
-
@mock_warden.expects(:user).times(Devise.mappings.size)
|
161
|
-
@mock_warden.expects(:logout).with().returns(true)
|
162
|
-
@mock_warden.expects(:clear_strategies_cache!).with().returns(true)
|
163
|
-
@controller.sign_out
|
164
|
-
end
|
165
|
-
|
166
|
-
test 'sign out everybody proxy to logout on warden' do
|
167
|
-
@mock_warden.expects(:user).times(Devise.mappings.size)
|
168
|
-
@mock_warden.expects(:logout).with().returns(true)
|
169
|
-
@controller.sign_out_all_scopes
|
170
|
-
end
|
171
|
-
|
172
|
-
test 'stored location for returns the location for a given scope' do
|
173
|
-
assert_nil @controller.stored_location_for(:user)
|
174
|
-
@controller.session[:"user_return_to"] = "/foo.bar"
|
175
|
-
assert_equal "/foo.bar", @controller.stored_location_for(:user)
|
176
|
-
end
|
177
|
-
|
178
|
-
test 'stored location for accepts a resource as argument' do
|
179
|
-
assert_nil @controller.stored_location_for(:user)
|
180
|
-
@controller.session[:"user_return_to"] = "/foo.bar"
|
181
|
-
assert_equal "/foo.bar", @controller.stored_location_for(User.new)
|
182
|
-
end
|
183
|
-
|
184
|
-
test 'stored location cleans information after reading' do
|
185
|
-
@controller.session[:"user_return_to"] = "/foo.bar"
|
186
|
-
assert_equal "/foo.bar", @controller.stored_location_for(:user)
|
187
|
-
assert_nil @controller.session[:"user_return_to"]
|
188
|
-
end
|
189
|
-
|
190
|
-
test 'store location for stores a location to redirect back to' do
|
191
|
-
assert_nil @controller.stored_location_for(:user)
|
192
|
-
@controller.store_location_for(:user, "/foo.bar")
|
193
|
-
assert_equal "/foo.bar", @controller.stored_location_for(:user)
|
194
|
-
end
|
195
|
-
|
196
|
-
test 'store location for accepts a resource as argument' do
|
197
|
-
@controller.store_location_for(User.new, "/foo.bar")
|
198
|
-
assert_equal "/foo.bar", @controller.stored_location_for(User.new)
|
199
|
-
end
|
200
|
-
|
201
|
-
test 'store location for stores paths' do
|
202
|
-
@controller.store_location_for(:user, "//host/foo.bar")
|
203
|
-
assert_equal "/foo.bar", @controller.stored_location_for(:user)
|
204
|
-
@controller.store_location_for(:user, "///foo.bar")
|
205
|
-
assert_equal "/foo.bar", @controller.stored_location_for(:user)
|
206
|
-
end
|
207
|
-
|
208
|
-
test 'store location for stores query string' do
|
209
|
-
@controller.store_location_for(:user, "/foo?bar=baz")
|
210
|
-
assert_equal "/foo?bar=baz", @controller.stored_location_for(:user)
|
211
|
-
end
|
212
|
-
|
213
|
-
test 'after sign in path defaults to root path if none by was specified for the given scope' do
|
214
|
-
assert_equal root_path, @controller.after_sign_in_path_for(:user)
|
215
|
-
end
|
216
|
-
|
217
|
-
test 'after sign in path defaults to the scoped root path' do
|
218
|
-
assert_equal admin_root_path, @controller.after_sign_in_path_for(:admin)
|
219
|
-
end
|
220
|
-
|
221
|
-
test 'after sign out path defaults to the root path' do
|
222
|
-
assert_equal root_path, @controller.after_sign_out_path_for(:admin)
|
223
|
-
assert_equal root_path, @controller.after_sign_out_path_for(:user)
|
224
|
-
end
|
225
|
-
|
226
|
-
test 'sign in and redirect uses the stored location' do
|
227
|
-
user = User.new
|
228
|
-
@controller.session[:user_return_to] = "/foo.bar"
|
229
|
-
@mock_warden.expects(:user).with(:user).returns(nil)
|
230
|
-
@mock_warden.expects(:set_user).with(user, scope: :user).returns(true)
|
231
|
-
@controller.expects(:redirect_to).with("/foo.bar")
|
232
|
-
@controller.sign_in_and_redirect(user)
|
233
|
-
end
|
234
|
-
|
235
|
-
test 'sign in and redirect uses the configured after sign in path' do
|
236
|
-
admin = Admin.new
|
237
|
-
@mock_warden.expects(:user).with(:admin).returns(nil)
|
238
|
-
@mock_warden.expects(:set_user).with(admin, scope: :admin).returns(true)
|
239
|
-
@controller.expects(:redirect_to).with(admin_root_path)
|
240
|
-
@controller.sign_in_and_redirect(admin)
|
241
|
-
end
|
242
|
-
|
243
|
-
test 'sign in and redirect does not sign in again if user is already signed' do
|
244
|
-
admin = Admin.new
|
245
|
-
@mock_warden.expects(:user).with(:admin).returns(admin)
|
246
|
-
@mock_warden.expects(:set_user).never
|
247
|
-
@controller.expects(:redirect_to).with(admin_root_path)
|
248
|
-
@controller.sign_in_and_redirect(admin)
|
249
|
-
end
|
250
|
-
|
251
|
-
test 'sign out and redirect uses the configured after sign out path when signing out only the current scope' do
|
252
|
-
swap Devise, sign_out_all_scopes: false do
|
253
|
-
@mock_warden.expects(:user).with(scope: :admin, run_callbacks: false).returns(true)
|
254
|
-
@mock_warden.expects(:logout).with(:admin).returns(true)
|
255
|
-
@mock_warden.expects(:clear_strategies_cache!).with(scope: :admin).returns(true)
|
256
|
-
@controller.expects(:redirect_to).with(admin_root_path)
|
257
|
-
@controller.instance_eval "def after_sign_out_path_for(resource); admin_root_path; end"
|
258
|
-
@controller.sign_out_and_redirect(:admin)
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
test 'sign out and redirect uses the configured after sign out path when signing out all scopes' do
|
263
|
-
swap Devise, sign_out_all_scopes: true do
|
264
|
-
@mock_warden.expects(:user).times(Devise.mappings.size)
|
265
|
-
@mock_warden.expects(:logout).with().returns(true)
|
266
|
-
@mock_warden.expects(:clear_strategies_cache!).with().returns(true)
|
267
|
-
@controller.expects(:redirect_to).with(admin_root_path)
|
268
|
-
@controller.instance_eval "def after_sign_out_path_for(resource); admin_root_path; end"
|
269
|
-
@controller.sign_out_and_redirect(:admin)
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
test 'is not a devise controller' do
|
274
|
-
assert_not @controller.devise_controller?
|
275
|
-
end
|
276
|
-
end
|