devise_token_auth 0.1.37.beta4 → 0.1.37
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of devise_token_auth might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/app/controllers/devise_token_auth/application_controller.rb +4 -0
- data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +5 -5
- data/app/controllers/devise_token_auth/passwords_controller.rb +3 -3
- data/app/controllers/devise_token_auth/registrations_controller.rb +9 -8
- data/app/controllers/devise_token_auth/sessions_controller.rb +3 -3
- data/app/controllers/devise_token_auth/token_validations_controller.rb +2 -2
- data/app/models/devise_token_auth/concerns/user.rb +17 -3
- data/app/validators/email_validator.rb +6 -6
- data/config/locales/de.yml +12 -12
- data/config/locales/en.yml +20 -20
- data/config/locales/es.yml +24 -24
- data/config/locales/fr.yml +17 -17
- data/config/locales/pl.yml +15 -15
- data/config/locales/pt-BR.yml +9 -12
- data/config/locales/pt.yml +7 -7
- data/config/locales/ru.yml +18 -18
- data/config/locales/zh-HK.yml +49 -0
- data/config/locales/zh-TW.yml +49 -0
- data/lib/devise_token_auth/controllers/helpers.rb +11 -7
- data/lib/devise_token_auth/engine.rb +3 -1
- data/lib/devise_token_auth/rails/routes.rb +7 -1
- data/lib/devise_token_auth/version.rb +1 -1
- data/lib/generators/devise_token_auth/templates/devise_token_auth.rb +2 -2
- data/test/controllers/demo_user_controller_test.rb +42 -0
- data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +0 -13
- data/test/controllers/devise_token_auth/token_validations_controller_test.rb +25 -0
- data/test/dummy/app/controllers/application_controller.rb +6 -5
- data/test/dummy/{tmp/generators/app/models/user.rb → app/models/scoped_user.rb} +1 -5
- data/test/dummy/config/routes.rb +13 -0
- data/test/dummy/{tmp/generators/db/migrate/20151027080542_devise_token_auth_create_users.rb → db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb} +15 -9
- data/test/dummy/db/schema.rb +30 -1
- data/test/dummy/tmp/generators/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/test/dummy/tmp/generators/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- metadata +27 -17
- data/test/dummy/tmp/generators/config/initializers/devise_token_auth.rb +0 -28
@@ -17,7 +17,6 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
17
17
|
end
|
18
18
|
|
19
19
|
describe 'success callback' do
|
20
|
-
|
21
20
|
setup do
|
22
21
|
OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new({
|
23
22
|
:provider => 'facebook',
|
@@ -125,13 +124,11 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
125
124
|
end
|
126
125
|
|
127
126
|
describe "oauth registration attr" do
|
128
|
-
|
129
127
|
after do
|
130
128
|
User.any_instance.unstub(:new_record?)
|
131
129
|
end
|
132
130
|
|
133
131
|
describe 'with new user' do
|
134
|
-
|
135
132
|
before do
|
136
133
|
User.any_instance.expects(:new_record?).returns(true).at_least_once
|
137
134
|
end
|
@@ -148,7 +145,6 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
148
145
|
end
|
149
146
|
|
150
147
|
describe 'with existing user' do
|
151
|
-
|
152
148
|
before do
|
153
149
|
User.any_instance.expects(:new_record?).returns(false).at_least_once
|
154
150
|
end
|
@@ -191,7 +187,6 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
191
187
|
end
|
192
188
|
|
193
189
|
describe 'with omniauth_window_type=inAppBrowser' do
|
194
|
-
|
195
190
|
test 'response contains all expected data' do
|
196
191
|
get_success(omniauth_window_type: 'inAppBrowser')
|
197
192
|
assert_expected_data_in_new_window
|
@@ -200,7 +195,6 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
200
195
|
end
|
201
196
|
|
202
197
|
describe 'with omniauth_window_type=newWindow' do
|
203
|
-
|
204
198
|
test 'response contains all expected data' do
|
205
199
|
get_success(omniauth_window_type: 'newWindow')
|
206
200
|
assert_expected_data_in_new_window
|
@@ -216,7 +210,6 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
216
210
|
end
|
217
211
|
|
218
212
|
describe 'with omniauth_window_type=sameWindow' do
|
219
|
-
|
220
213
|
test 'redirects to auth_origin_url with all expected query params' do
|
221
214
|
get_via_redirect '/auth/facebook', {
|
222
215
|
auth_origin_url: '/auth_origin',
|
@@ -247,14 +240,9 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
247
240
|
assert_equal 200, response.status
|
248
241
|
@resource = assigns(:resource)
|
249
242
|
end
|
250
|
-
|
251
|
-
|
252
|
-
|
253
243
|
end
|
254
244
|
|
255
245
|
describe 'failure callback' do
|
256
|
-
|
257
|
-
|
258
246
|
setup do
|
259
247
|
OmniAuth.config.mock_auth[:facebook] = :invalid_credentials
|
260
248
|
OmniAuth.config.on_failure = Proc.new { |env|
|
@@ -280,7 +268,6 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
280
268
|
assert_equal 200, response.status
|
281
269
|
assert_select "body", "invalid_credentials"
|
282
270
|
end
|
283
|
-
|
284
271
|
end
|
285
272
|
|
286
273
|
describe 'User with only :database_authenticatable and :registerable included' do
|
@@ -63,4 +63,29 @@ class DeviseTokenAuth::TokenValidationsControllerTest < ActionDispatch::Integrat
|
|
63
63
|
end
|
64
64
|
|
65
65
|
end
|
66
|
+
|
67
|
+
describe 'using namespaces with unused resource' do
|
68
|
+
|
69
|
+
before do
|
70
|
+
@resource = scoped_users(:confirmed_email_user)
|
71
|
+
@resource.skip_confirmation!
|
72
|
+
@resource.save!
|
73
|
+
|
74
|
+
@auth_headers = @resource.create_new_auth_token
|
75
|
+
|
76
|
+
@token = @auth_headers['access-token']
|
77
|
+
@client_id = @auth_headers['client']
|
78
|
+
@expiry = @auth_headers['expiry']
|
79
|
+
|
80
|
+
# ensure that request is not treated as batch request
|
81
|
+
age_token(@resource, @client_id)
|
82
|
+
end
|
83
|
+
|
84
|
+
test "should be successful" do
|
85
|
+
get '/api_v2/auth/validate_token', {}, @auth_headers
|
86
|
+
assert_equal 200, response.status
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
66
91
|
end
|
@@ -6,10 +6,11 @@ class ApplicationController < ActionController::Base
|
|
6
6
|
protected
|
7
7
|
|
8
8
|
def configure_permitted_parameters
|
9
|
-
devise_parameter_sanitizer.
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
permitted_parameters = devise_parameter_sanitizer.instance_values['permitted']
|
10
|
+
permitted_parameters[:sign_up] << :operating_thetan
|
11
|
+
permitted_parameters[:sign_up] << :favorite_color
|
12
|
+
permitted_parameters[:account_update] << :operating_thetan
|
13
|
+
permitted_parameters[:account_update] << :favorite_color
|
14
|
+
permitted_parameters[:account_update] << :current_password
|
14
15
|
end
|
15
16
|
end
|
@@ -1,11 +1,7 @@
|
|
1
|
-
class
|
1
|
+
class ScopedUser < ActiveRecord::Base
|
2
2
|
# Include default devise modules.
|
3
3
|
devise :database_authenticatable, :registerable,
|
4
4
|
:recoverable, :rememberable, :trackable, :validatable,
|
5
5
|
:confirmable, :omniauthable
|
6
6
|
include DeviseTokenAuth::Concerns::User
|
7
|
-
|
8
|
-
def whatever
|
9
|
-
puts 'whatever'
|
10
|
-
end
|
11
7
|
end
|
data/test/dummy/config/routes.rb
CHANGED
@@ -41,6 +41,19 @@ Rails.application.routes.draw do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
# test namespacing with not created devise mapping
|
45
|
+
namespace :api_v2, defaults: { format: :json } do
|
46
|
+
mount_devise_token_auth_for "ScopedUser",
|
47
|
+
at: "auth",
|
48
|
+
controllers: {
|
49
|
+
omniauth_callbacks: "api_v2/omniauth_callbacks",
|
50
|
+
sessions: "api_v2/sessions",
|
51
|
+
registrations: "api_v2/registrations",
|
52
|
+
confirmations: "api_v2/confirmations",
|
53
|
+
passwords: "api_v2/passwords"
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
44
57
|
# this route will authorize visitors using the User class
|
45
58
|
get 'demo/members_only', to: 'demo_user#members_only'
|
46
59
|
|
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
include MigrationDatabaseHelper
|
2
|
+
|
3
|
+
class DeviseTokenAuthCreateScopedUsers < ActiveRecord::Migration
|
2
4
|
def change
|
3
|
-
create_table(:
|
5
|
+
create_table(:scoped_users) do |t|
|
4
6
|
## Required
|
5
|
-
t.string :provider, :null => false
|
7
|
+
t.string :provider, :null => false
|
6
8
|
t.string :uid, :null => false, :default => ""
|
7
9
|
|
8
10
|
## Database authenticatable
|
@@ -40,15 +42,19 @@ class DeviseTokenAuthCreateUsers < ActiveRecord::Migration
|
|
40
42
|
t.string :email
|
41
43
|
|
42
44
|
## Tokens
|
43
|
-
|
45
|
+
if json_supported_database?
|
46
|
+
t.json :tokens
|
47
|
+
else
|
48
|
+
t.text :tokens
|
49
|
+
end
|
44
50
|
|
45
51
|
t.timestamps
|
46
52
|
end
|
47
53
|
|
48
|
-
add_index :
|
49
|
-
add_index :
|
50
|
-
add_index :
|
51
|
-
# add_index :
|
52
|
-
# add_index :
|
54
|
+
add_index :scoped_users, :email
|
55
|
+
add_index :scoped_users, [:uid, :provider], :unique => true
|
56
|
+
add_index :scoped_users, :reset_password_token, :unique => true
|
57
|
+
# add_index :scoped_users, :confirmation_token, :unique => true
|
58
|
+
# add_index :scoped_users, :unlock_token, :unique => true
|
53
59
|
end
|
54
60
|
end
|
data/test/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20160103235141) do
|
15
15
|
|
16
16
|
create_table "evil_users", force: :cascade do |t|
|
17
17
|
t.string "email"
|
@@ -122,6 +122,35 @@ ActiveRecord::Schema.define(version: 20150708104536) do
|
|
122
122
|
add_index "only_email_users", ["email"], name: "index_only_email_users_on_email"
|
123
123
|
add_index "only_email_users", ["uid", "provider"], name: "index_only_email_users_on_uid_and_provider", unique: true
|
124
124
|
|
125
|
+
create_table "scoped_users", force: :cascade do |t|
|
126
|
+
t.string "provider", null: false
|
127
|
+
t.string "uid", default: "", null: false
|
128
|
+
t.string "encrypted_password", default: "", null: false
|
129
|
+
t.string "reset_password_token"
|
130
|
+
t.datetime "reset_password_sent_at"
|
131
|
+
t.datetime "remember_created_at"
|
132
|
+
t.integer "sign_in_count", default: 0, null: false
|
133
|
+
t.datetime "current_sign_in_at"
|
134
|
+
t.datetime "last_sign_in_at"
|
135
|
+
t.string "current_sign_in_ip"
|
136
|
+
t.string "last_sign_in_ip"
|
137
|
+
t.string "confirmation_token"
|
138
|
+
t.datetime "confirmed_at"
|
139
|
+
t.datetime "confirmation_sent_at"
|
140
|
+
t.string "unconfirmed_email"
|
141
|
+
t.string "name"
|
142
|
+
t.string "nickname"
|
143
|
+
t.string "image"
|
144
|
+
t.string "email"
|
145
|
+
t.text "tokens"
|
146
|
+
t.datetime "created_at"
|
147
|
+
t.datetime "updated_at"
|
148
|
+
end
|
149
|
+
|
150
|
+
add_index "scoped_users", ["email"], name: "index_scoped_users_on_email"
|
151
|
+
add_index "scoped_users", ["reset_password_token"], name: "index_scoped_users_on_reset_password_token", unique: true
|
152
|
+
add_index "scoped_users", ["uid", "provider"], name: "index_scoped_users_on_uid_and_provider", unique: true
|
153
|
+
|
125
154
|
create_table "unconfirmable_users", force: :cascade do |t|
|
126
155
|
t.string "provider", null: false
|
127
156
|
t.string "uid", default: "", null: false
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<p><%= t(:welcome).capitalize + ' ' + @email %>!</p>
|
2
|
+
|
3
|
+
<p><%= t '.confirm_link_msg' %> </p>
|
4
|
+
|
5
|
+
<p><%= link_to t('.confirm_account_link'), confirmation_url(@resource, {confirmation_token: @token, config: message['client-config'].to_s, redirect_url: message['redirect-url']}).html_safe %></p>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<p><%= t(:hello).capitalize %> <%= @resource.email %>!</p>
|
2
|
+
|
3
|
+
<p><%= t '.request_reset_link_msg' %></p>
|
4
|
+
|
5
|
+
<p><%= link_to t('.password_change_link'), edit_password_url(@resource, reset_password_token: @token, config: message['client-config'].to_s, redirect_url: message['redirect-url'].to_s).html_safe %></p>
|
6
|
+
|
7
|
+
<p><%= t '.ignore_mail_msg' %></p>
|
8
|
+
<p><%= t '.no_changes_msg' %></p>
|
metadata
CHANGED
@@ -1,43 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_token_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.37
|
4
|
+
version: 0.1.37
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lynn Hurley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "<"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: devise
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 3.5.2
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '4.1'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- - "
|
41
|
+
- - ">"
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: 3.5.2
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '4.1'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: sqlite3
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,6 +119,8 @@ files:
|
|
113
119
|
- config/locales/pt-BR.yml
|
114
120
|
- config/locales/pt.yml
|
115
121
|
- config/locales/ru.yml
|
122
|
+
- config/locales/zh-HK.yml
|
123
|
+
- config/locales/zh-TW.yml
|
116
124
|
- lib/devise_token_auth.rb
|
117
125
|
- lib/devise_token_auth/controllers/helpers.rb
|
118
126
|
- lib/devise_token_auth/controllers/url_helpers.rb
|
@@ -171,6 +179,7 @@ files:
|
|
171
179
|
- test/dummy/app/models/mang.rb
|
172
180
|
- test/dummy/app/models/nice_user.rb
|
173
181
|
- test/dummy/app/models/only_email_user.rb
|
182
|
+
- test/dummy/app/models/scoped_user.rb
|
174
183
|
- test/dummy/app/models/unconfirmable_user.rb
|
175
184
|
- test/dummy/app/models/unregisterable_user.rb
|
176
185
|
- test/dummy/app/models/user.rb
|
@@ -206,11 +215,11 @@ files:
|
|
206
215
|
- test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb
|
207
216
|
- test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb
|
208
217
|
- test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb
|
218
|
+
- test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb
|
209
219
|
- test/dummy/db/schema.rb
|
210
220
|
- test/dummy/lib/migration_database_helper.rb
|
211
|
-
- test/dummy/tmp/generators/app/
|
212
|
-
- test/dummy/tmp/generators/
|
213
|
-
- test/dummy/tmp/generators/db/migrate/20151027080542_devise_token_auth_create_users.rb
|
221
|
+
- test/dummy/tmp/generators/app/views/devise/mailer/confirmation_instructions.html.erb
|
222
|
+
- test/dummy/tmp/generators/app/views/devise/mailer/reset_password_instructions.html.erb
|
214
223
|
- test/integration/navigation_test.rb
|
215
224
|
- test/lib/devise_token_auth/url_test.rb
|
216
225
|
- test/lib/generators/devise_token_auth/install_generator_test.rb
|
@@ -233,12 +242,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
233
242
|
version: '0'
|
234
243
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
235
244
|
requirements:
|
236
|
-
- - "
|
245
|
+
- - ">="
|
237
246
|
- !ruby/object:Gem::Version
|
238
|
-
version:
|
247
|
+
version: '0'
|
239
248
|
requirements: []
|
240
249
|
rubyforge_project:
|
241
|
-
rubygems_version: 2.
|
250
|
+
rubygems_version: 2.4.8
|
242
251
|
signing_key:
|
243
252
|
specification_version: 4
|
244
253
|
summary: Token based authentication for rails. Uses Devise + OmniAuth.
|
@@ -286,6 +295,7 @@ test_files:
|
|
286
295
|
- test/dummy/app/models/mang.rb
|
287
296
|
- test/dummy/app/models/nice_user.rb
|
288
297
|
- test/dummy/app/models/only_email_user.rb
|
298
|
+
- test/dummy/app/models/scoped_user.rb
|
289
299
|
- test/dummy/app/models/unconfirmable_user.rb
|
290
300
|
- test/dummy/app/models/unregisterable_user.rb
|
291
301
|
- test/dummy/app/models/user.rb
|
@@ -321,12 +331,12 @@ test_files:
|
|
321
331
|
- test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb
|
322
332
|
- test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb
|
323
333
|
- test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb
|
334
|
+
- test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb
|
324
335
|
- test/dummy/db/schema.rb
|
325
336
|
- test/dummy/lib/migration_database_helper.rb
|
326
337
|
- test/dummy/README.rdoc
|
327
|
-
- test/dummy/tmp/generators/app/
|
328
|
-
- test/dummy/tmp/generators/
|
329
|
-
- test/dummy/tmp/generators/db/migrate/20151027080542_devise_token_auth_create_users.rb
|
338
|
+
- test/dummy/tmp/generators/app/views/devise/mailer/confirmation_instructions.html.erb
|
339
|
+
- test/dummy/tmp/generators/app/views/devise/mailer/reset_password_instructions.html.erb
|
330
340
|
- test/integration/navigation_test.rb
|
331
341
|
- test/lib/devise_token_auth/url_test.rb
|
332
342
|
- test/lib/generators/devise_token_auth/install_generator_test.rb
|
@@ -1,28 +0,0 @@
|
|
1
|
-
DeviseTokenAuth.setup do |config|
|
2
|
-
# By default the authorization headers will change after each request. The
|
3
|
-
# client is responsible for keeping track of the changing tokens. Change
|
4
|
-
# this to false to prevent the Authorization header from changing after
|
5
|
-
# each request.
|
6
|
-
#config.change_headers_on_each_request = true
|
7
|
-
|
8
|
-
# By default, users will need to re-authenticate after 2 weeks. This setting
|
9
|
-
# determines how long tokens will remain valid after they are issued.
|
10
|
-
#config.token_lifespan = 2.weeks
|
11
|
-
|
12
|
-
# Sometimes it's necessary to make several requests to the API at the same
|
13
|
-
# time. In this case, each request in the batch will need to share the same
|
14
|
-
# auth token. This setting determines how far apart the requests can be while
|
15
|
-
# still using the same auth token.
|
16
|
-
#config.batch_request_buffer_throttle = 5.seconds
|
17
|
-
|
18
|
-
# This route will be the prefix for all oauth2 redirect callbacks. For
|
19
|
-
# example, using the default '/omniauth', the github oauth2 provider will
|
20
|
-
# redirect successful authentications to '/omniauth/github/callback'
|
21
|
-
#config.omniauth_prefix = "/omniauth"
|
22
|
-
|
23
|
-
# By defult sending current password is not needed for the password update.
|
24
|
-
# Uncomment to enforce current_password param to be checked before all
|
25
|
-
# attribute updates. Set it to :password if you want it to be checked only if
|
26
|
-
# password is updated.
|
27
|
-
# config.check_current_password_before_update = :attributes
|
28
|
-
end
|