devise_token_auth 1.0.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +4 -2
  3. data/app/controllers/devise_token_auth/application_controller.rb +19 -3
  4. data/app/controllers/devise_token_auth/concerns/resource_finder.rb +23 -11
  5. data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +78 -57
  6. data/app/controllers/devise_token_auth/confirmations_controller.rb +67 -20
  7. data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +82 -30
  8. data/app/controllers/devise_token_auth/passwords_controller.rb +53 -31
  9. data/app/controllers/devise_token_auth/registrations_controller.rb +33 -40
  10. data/app/controllers/devise_token_auth/sessions_controller.rb +24 -6
  11. data/app/controllers/devise_token_auth/unlocks_controller.rb +10 -6
  12. data/app/models/devise_token_auth/concerns/active_record_support.rb +14 -0
  13. data/app/models/devise_token_auth/concerns/confirmable_support.rb +28 -0
  14. data/app/models/devise_token_auth/concerns/mongoid_support.rb +19 -0
  15. data/app/models/devise_token_auth/concerns/tokens_serialization.rb +31 -0
  16. data/app/models/devise_token_auth/concerns/user.rb +77 -80
  17. data/app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb +12 -5
  18. data/app/validators/{email_validator.rb → devise_token_auth_email_validator.rb} +11 -3
  19. data/app/views/devise_token_auth/omniauth_external_window.html.erb +1 -1
  20. data/config/locales/da-DK.yml +2 -0
  21. data/config/locales/de.yml +2 -0
  22. data/config/locales/en.yml +10 -0
  23. data/config/locales/es.yml +2 -0
  24. data/config/locales/fr.yml +2 -0
  25. data/config/locales/he.yml +52 -0
  26. data/config/locales/it.yml +2 -0
  27. data/config/locales/ja.yml +16 -2
  28. data/config/locales/ko.yml +51 -0
  29. data/config/locales/nl.yml +2 -0
  30. data/config/locales/pl.yml +6 -3
  31. data/config/locales/pt-BR.yml +2 -0
  32. data/config/locales/pt.yml +6 -3
  33. data/config/locales/ro.yml +2 -0
  34. data/config/locales/ru.yml +2 -0
  35. data/config/locales/sq.yml +2 -0
  36. data/config/locales/sv.yml +2 -0
  37. data/config/locales/uk.yml +2 -0
  38. data/config/locales/vi.yml +2 -0
  39. data/config/locales/zh-CN.yml +2 -0
  40. data/config/locales/zh-HK.yml +2 -0
  41. data/config/locales/zh-TW.yml +2 -0
  42. data/lib/devise_token_auth/blacklist.rb +6 -0
  43. data/lib/devise_token_auth/controllers/helpers.rb +5 -9
  44. data/lib/devise_token_auth/engine.rb +17 -2
  45. data/lib/devise_token_auth/rails/routes.rb +18 -13
  46. data/lib/devise_token_auth/token_factory.rb +126 -0
  47. data/lib/devise_token_auth/url.rb +3 -0
  48. data/lib/devise_token_auth/version.rb +1 -1
  49. data/lib/devise_token_auth.rb +6 -3
  50. data/lib/generators/devise_token_auth/USAGE +1 -1
  51. data/lib/generators/devise_token_auth/install_generator.rb +7 -91
  52. data/lib/generators/devise_token_auth/install_generator_helpers.rb +98 -0
  53. data/lib/generators/devise_token_auth/install_mongoid_generator.rb +46 -0
  54. data/lib/generators/devise_token_auth/templates/devise_token_auth.rb +13 -0
  55. data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +1 -8
  56. data/lib/generators/devise_token_auth/templates/user.rb.erb +2 -2
  57. data/lib/generators/devise_token_auth/templates/user_mongoid.rb.erb +56 -0
  58. data/test/controllers/custom/custom_confirmations_controller_test.rb +1 -1
  59. data/test/controllers/demo_mang_controller_test.rb +37 -8
  60. data/test/controllers/demo_user_controller_test.rb +39 -10
  61. data/test/controllers/devise_token_auth/confirmations_controller_test.rb +163 -18
  62. data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +110 -43
  63. data/test/controllers/devise_token_auth/passwords_controller_test.rb +299 -122
  64. data/test/controllers/devise_token_auth/registrations_controller_test.rb +54 -14
  65. data/test/controllers/devise_token_auth/sessions_controller_test.rb +31 -40
  66. data/test/controllers/devise_token_auth/token_validations_controller_test.rb +43 -2
  67. data/test/controllers/devise_token_auth/unlocks_controller_test.rb +44 -5
  68. data/test/controllers/overrides/confirmations_controller_test.rb +1 -1
  69. data/test/dummy/app/active_record/confirmable_user.rb +11 -0
  70. data/test/dummy/app/{models → active_record}/scoped_user.rb +2 -2
  71. data/test/dummy/app/{models → active_record}/unconfirmable_user.rb +1 -2
  72. data/test/dummy/app/{models → active_record}/unregisterable_user.rb +3 -3
  73. data/test/dummy/app/active_record/user.rb +6 -0
  74. data/test/dummy/app/controllers/overrides/confirmations_controller.rb +3 -3
  75. data/test/dummy/app/controllers/overrides/passwords_controller.rb +3 -3
  76. data/test/dummy/app/controllers/overrides/registrations_controller.rb +1 -1
  77. data/test/dummy/app/controllers/overrides/sessions_controller.rb +2 -2
  78. data/test/dummy/app/models/{user.rb → concerns/favorite_color.rb} +7 -8
  79. data/test/dummy/app/mongoid/confirmable_user.rb +52 -0
  80. data/test/dummy/app/mongoid/lockable_user.rb +38 -0
  81. data/test/dummy/app/mongoid/mang.rb +46 -0
  82. data/test/dummy/app/mongoid/only_email_user.rb +33 -0
  83. data/test/dummy/app/mongoid/scoped_user.rb +50 -0
  84. data/test/dummy/app/mongoid/unconfirmable_user.rb +44 -0
  85. data/test/dummy/app/mongoid/unregisterable_user.rb +47 -0
  86. data/test/dummy/app/mongoid/user.rb +49 -0
  87. data/test/dummy/app/views/layouts/application.html.erb +0 -2
  88. data/test/dummy/config/application.rb +22 -1
  89. data/test/dummy/config/boot.rb +4 -0
  90. data/test/dummy/config/environments/development.rb +0 -10
  91. data/test/dummy/config/environments/production.rb +0 -16
  92. data/test/dummy/config/initializers/devise.rb +285 -0
  93. data/test/dummy/config/initializers/devise_token_auth.rb +35 -4
  94. data/test/dummy/config/initializers/figaro.rb +1 -1
  95. data/test/dummy/config/initializers/omniauth.rb +1 -0
  96. data/test/dummy/config/routes.rb +2 -0
  97. data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +0 -7
  98. data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +0 -7
  99. data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +0 -7
  100. data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +0 -7
  101. data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +0 -7
  102. data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +0 -7
  103. data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +0 -7
  104. data/test/dummy/db/migrate/20190924101113_devise_token_auth_create_confirmable_users.rb +49 -0
  105. data/test/dummy/db/schema.rb +31 -33
  106. data/test/dummy/tmp/generators/app/models/user.rb +11 -0
  107. data/test/dummy/tmp/generators/config/initializers/devise_token_auth.rb +60 -0
  108. data/test/dummy/tmp/generators/db/migrate/20220822003050_devise_token_auth_create_users.rb +49 -0
  109. data/test/factories/users.rb +3 -2
  110. data/test/lib/devise_token_auth/blacklist_test.rb +19 -0
  111. data/test/lib/devise_token_auth/rails/custom_routes_test.rb +29 -0
  112. data/test/lib/devise_token_auth/rails/routes_test.rb +87 -0
  113. data/test/lib/devise_token_auth/token_factory_test.rb +191 -0
  114. data/test/lib/devise_token_auth/url_test.rb +2 -2
  115. data/test/lib/generators/devise_token_auth/install_generator_test.rb +51 -31
  116. data/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +51 -31
  117. data/test/models/concerns/mongoid_support_test.rb +31 -0
  118. data/test/models/concerns/tokens_serialization_test.rb +104 -0
  119. data/test/models/confirmable_user_test.rb +35 -0
  120. data/test/models/only_email_user_test.rb +0 -8
  121. data/test/models/user_test.rb +13 -23
  122. data/test/test_helper.rb +45 -4
  123. metadata +126 -33
  124. data/config/initializers/devise.rb +0 -198
  125. data/test/dummy/config/initializers/assets.rb +0 -10
  126. data/test/dummy/tmp/generators/app/views/devise/mailer/confirmation_instructions.html.erb +0 -5
  127. data/test/dummy/tmp/generators/app/views/devise/mailer/reset_password_instructions.html.erb +0 -8
  128. /data/test/dummy/app/{models → active_record}/lockable_user.rb +0 -0
  129. /data/test/dummy/app/{models → active_record}/mang.rb +0 -0
  130. /data/test/dummy/app/{models → active_record}/only_email_user.rb +0 -0
@@ -44,7 +44,7 @@ class UserTest < ActiveSupport::TestCase
44
44
  @resource = build(:user, user_attributes)
45
45
 
46
46
  refute @resource.save
47
- assert @resource.errors.messages[:email] == [I18n.t('errors.messages.taken')]
47
+ assert @resource.errors.messages[:email].first.include? 'taken'
48
48
  assert @resource.errors.messages[:email].none? { |e| e =~ /translation missing/ }
49
49
  end
50
50
  end
@@ -76,35 +76,25 @@ class UserTest < ActiveSupport::TestCase
76
76
  end
77
77
  end
78
78
 
79
- describe 'user specific token lifespan' do
79
+ describe 'previous token' do
80
80
  before do
81
81
  @resource = create(:user, :confirmed)
82
82
 
83
- auth_headers = @resource.create_new_auth_token
84
- @token_global = auth_headers['access-token']
85
- @client_id_global = auth_headers['client']
86
-
87
- def @resource.token_lifespan
88
- 1.minute
89
- end
90
-
91
- auth_headers = @resource.create_new_auth_token
92
- @token_specific = auth_headers['access-token']
93
- @client_id_specific = auth_headers['client']
83
+ @auth_headers1 = @resource.create_new_auth_token
94
84
  end
95
85
 
96
- test 'works per user' do
97
- assert @resource.token_is_current?(@token_global, @client_id_global)
98
-
99
- time = Time.zone.now.to_i
100
- expiry_global = @resource.tokens[@client_id_global]['expiry'] || @resource.tokens[@client_id_global][:expiry]
86
+ test 'should properly indicate whether previous token is current' do
87
+ assert @resource.token_is_current?(@auth_headers1['access-token'], @auth_headers1['client'])
88
+ # create another token, emulating a new request
89
+ @auth_headers2 = @resource.create_new_auth_token
101
90
 
102
- assert expiry_global > time + DeviseTokenAuth.token_lifespan - 5.seconds
103
- assert expiry_global < time + DeviseTokenAuth.token_lifespan + 5.seconds
91
+ # should work for previous token
92
+ assert @resource.token_is_current?(@auth_headers1['access-token'], @auth_headers1['client'])
93
+ # should work for latest token as well
94
+ assert @resource.token_is_current?(@auth_headers2['access-token'], @auth_headers2['client'])
104
95
 
105
- expiry_specific = @resource.tokens[@client_id_specific]['expiry'] || @resource.tokens[@client_id_specific][:expiry]
106
- assert expiry_specific > time + 55.seconds
107
- assert expiry_specific < time + 65.seconds
96
+ # after using latest token, previous token should not work
97
+ assert @resource.token_is_current?(@auth_headers1['access-token'], @auth_headers1['client'])
108
98
  end
109
99
  end
110
100
 
data/test/test_helper.rb CHANGED
@@ -7,11 +7,19 @@ SimpleCov.start 'rails' do
7
7
  end
8
8
 
9
9
  ENV['RAILS_ENV'] = 'test'
10
+ DEVISE_TOKEN_AUTH_ORM = (ENV['DEVISE_TOKEN_AUTH_ORM'] || :active_record).to_sym
11
+
12
+ puts "\n==> DeviseTokenAuth.orm = #{DEVISE_TOKEN_AUTH_ORM.inspect}"
10
13
 
11
14
  require File.expand_path('dummy/config/environment', __dir__)
12
- require 'rails/test_help'
15
+ require 'active_support/testing/autorun'
13
16
  require 'minitest/rails'
14
17
  require 'mocha/minitest'
18
+ if DEVISE_TOKEN_AUTH_ORM == :active_record
19
+ require 'database_cleaner'
20
+ else
21
+ require 'database_cleaner/mongoid'
22
+ end
15
23
 
16
24
  FactoryBot.definition_file_paths = [File.expand_path('factories', __dir__)]
17
25
  FactoryBot.find_definitions
@@ -30,13 +38,46 @@ end
30
38
  class ActiveSupport::TestCase
31
39
  include FactoryBot::Syntax::Methods
32
40
 
33
- ActiveRecord::Migration.check_pending!
41
+ ActiveRecord::Migration.check_pending! if DEVISE_TOKEN_AUTH_ORM == :active_record
42
+
43
+ strategies = { active_record: :transaction,
44
+ mongoid: :deletion }
45
+ DatabaseCleaner.strategy = strategies[DEVISE_TOKEN_AUTH_ORM]
46
+ setup { DatabaseCleaner.start }
47
+ teardown { DatabaseCleaner.clean }
34
48
 
35
49
  # Add more helper methods to be used by all tests here...
36
50
 
51
+ # Execute the block setting the given values and restoring old values after
52
+ # the block is executed.
53
+ # shamelessly copied from devise test_helper.
54
+ def swap(object, new_values)
55
+ old_values = {}
56
+ new_values.each do |key, value|
57
+ old_values[key] = object.send key
58
+ object.send :"#{key}=", value
59
+ end
60
+ clear_cached_variables(new_values)
61
+ yield
62
+ ensure
63
+ clear_cached_variables(new_values)
64
+ old_values.each do |key, value|
65
+ object.send :"#{key}=", value
66
+ end
67
+ end
68
+
69
+ # shamelessly copied from devise test_helper.
70
+ def clear_cached_variables(options)
71
+ if options.key?(:case_insensitive_keys) || options.key?(:strip_whitespace_keys)
72
+ Devise.mappings.each do |_, mapping|
73
+ mapping.to.instance_variable_set(:@devise_parameter_filter, nil)
74
+ end
75
+ end
76
+ end
77
+
37
78
  def age_token(user, client_id)
38
79
  if user.tokens[client_id]
39
- user.tokens[client_id]['updated_at'] = Time.zone.now - (DeviseTokenAuth.batch_request_buffer_throttle + 10.seconds)
80
+ user.tokens[client_id]['updated_at'] = (Time.zone.now - (DeviseTokenAuth.batch_request_buffer_throttle + 10.seconds))
40
81
  user.save!
41
82
  end
42
83
  end
@@ -75,7 +116,7 @@ module Rails
75
116
  %w[get post patch put head delete get_via_redirect post_via_redirect].each do |method|
76
117
  define_method(method) do |path_or_action, **args|
77
118
  if Rails::VERSION::MAJOR >= 5
78
- super path_or_action, args
119
+ super path_or_action, **args
79
120
  else
80
121
  super path_or_action, args[:params], args[:headers]
81
122
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_token_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lynn Hurley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-23 00:00:00.000000000 Z
11
+ date: 2022-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 4.2.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6'
22
+ version: '7.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 4.2.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6'
32
+ version: '7.1'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: devise
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: 3.5.2
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '4.6'
42
+ version: '5'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,21 @@ dependencies:
49
49
  version: 3.5.2
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '4.6'
52
+ version: '5'
53
+ - !ruby/object:Gem::Dependency
54
+ name: bcrypt
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '3.0'
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '3.0'
53
67
  - !ruby/object:Gem::Dependency
54
68
  name: appraisal
55
69
  requirement: !ruby/object:Gem::Requirement
@@ -70,14 +84,14 @@ dependencies:
70
84
  requirements:
71
85
  - - "~>"
72
86
  - !ruby/object:Gem::Version
73
- version: '1.3'
87
+ version: '1.4'
74
88
  type: :development
75
89
  prerelease: false
76
90
  version_requirements: !ruby/object:Gem::Requirement
77
91
  requirements:
78
92
  - - "~>"
79
93
  - !ruby/object:Gem::Version
80
- version: '1.3'
94
+ version: '1.4'
81
95
  - !ruby/object:Gem::Dependency
82
96
  name: pg
83
97
  requirement: !ruby/object:Gem::Requirement
@@ -106,6 +120,40 @@ dependencies:
106
120
  - - ">="
107
121
  - !ruby/object:Gem::Version
108
122
  version: '0'
123
+ - !ruby/object:Gem::Dependency
124
+ name: mongoid
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '4'
130
+ - - "<"
131
+ - !ruby/object:Gem::Version
132
+ version: '8'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '4'
140
+ - - "<"
141
+ - !ruby/object:Gem::Version
142
+ version: '8'
143
+ - !ruby/object:Gem::Dependency
144
+ name: mongoid-locker
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '1.0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - "~>"
155
+ - !ruby/object:Gem::Version
156
+ version: '1.0'
109
157
  description: For use with client side single page apps such as the venerable https://github.com/lynndylanhurley/ng-token-auth.
110
158
  email:
111
159
  - lynn.dylan.hurley@gmail.com
@@ -126,21 +174,26 @@ files:
126
174
  - app/controllers/devise_token_auth/sessions_controller.rb
127
175
  - app/controllers/devise_token_auth/token_validations_controller.rb
128
176
  - app/controllers/devise_token_auth/unlocks_controller.rb
177
+ - app/models/devise_token_auth/concerns/active_record_support.rb
178
+ - app/models/devise_token_auth/concerns/confirmable_support.rb
179
+ - app/models/devise_token_auth/concerns/mongoid_support.rb
180
+ - app/models/devise_token_auth/concerns/tokens_serialization.rb
129
181
  - app/models/devise_token_auth/concerns/user.rb
130
182
  - app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb
131
- - app/validators/email_validator.rb
183
+ - app/validators/devise_token_auth_email_validator.rb
132
184
  - app/views/devise/mailer/confirmation_instructions.html.erb
133
185
  - app/views/devise/mailer/reset_password_instructions.html.erb
134
186
  - app/views/devise/mailer/unlock_instructions.html.erb
135
187
  - app/views/devise_token_auth/omniauth_external_window.html.erb
136
- - config/initializers/devise.rb
137
188
  - config/locales/da-DK.yml
138
189
  - config/locales/de.yml
139
190
  - config/locales/en.yml
140
191
  - config/locales/es.yml
141
192
  - config/locales/fr.yml
193
+ - config/locales/he.yml
142
194
  - config/locales/it.yml
143
195
  - config/locales/ja.yml
196
+ - config/locales/ko.yml
144
197
  - config/locales/nl.yml
145
198
  - config/locales/pl.yml
146
199
  - config/locales/pt-BR.yml
@@ -155,19 +208,24 @@ files:
155
208
  - config/locales/zh-HK.yml
156
209
  - config/locales/zh-TW.yml
157
210
  - lib/devise_token_auth.rb
211
+ - lib/devise_token_auth/blacklist.rb
158
212
  - lib/devise_token_auth/controllers/helpers.rb
159
213
  - lib/devise_token_auth/controllers/url_helpers.rb
160
214
  - lib/devise_token_auth/engine.rb
161
215
  - lib/devise_token_auth/errors.rb
162
216
  - lib/devise_token_auth/rails/routes.rb
217
+ - lib/devise_token_auth/token_factory.rb
163
218
  - lib/devise_token_auth/url.rb
164
219
  - lib/devise_token_auth/version.rb
165
220
  - lib/generators/devise_token_auth/USAGE
166
221
  - lib/generators/devise_token_auth/install_generator.rb
222
+ - lib/generators/devise_token_auth/install_generator_helpers.rb
223
+ - lib/generators/devise_token_auth/install_mongoid_generator.rb
167
224
  - lib/generators/devise_token_auth/install_views_generator.rb
168
225
  - lib/generators/devise_token_auth/templates/devise_token_auth.rb
169
226
  - lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb
170
227
  - lib/generators/devise_token_auth/templates/user.rb.erb
228
+ - lib/generators/devise_token_auth/templates/user_mongoid.rb.erb
171
229
  - lib/tasks/devise_token_auth_tasks.rake
172
230
  - test/controllers/custom/custom_confirmations_controller_test.rb
173
231
  - test/controllers/custom/custom_omniauth_callbacks_controller_test.rb
@@ -192,6 +250,14 @@ files:
192
250
  - test/controllers/overrides/sessions_controller_test.rb
193
251
  - test/controllers/overrides/token_validations_controller_test.rb
194
252
  - test/dummy/README.rdoc
253
+ - test/dummy/app/active_record/confirmable_user.rb
254
+ - test/dummy/app/active_record/lockable_user.rb
255
+ - test/dummy/app/active_record/mang.rb
256
+ - test/dummy/app/active_record/only_email_user.rb
257
+ - test/dummy/app/active_record/scoped_user.rb
258
+ - test/dummy/app/active_record/unconfirmable_user.rb
259
+ - test/dummy/app/active_record/unregisterable_user.rb
260
+ - test/dummy/app/active_record/user.rb
195
261
  - test/dummy/app/controllers/application_controller.rb
196
262
  - test/dummy/app/controllers/auth_origin_controller.rb
197
263
  - test/dummy/app/controllers/custom/confirmations_controller.rb
@@ -210,13 +276,15 @@ files:
210
276
  - test/dummy/app/controllers/overrides/sessions_controller.rb
211
277
  - test/dummy/app/controllers/overrides/token_validations_controller.rb
212
278
  - test/dummy/app/helpers/application_helper.rb
213
- - test/dummy/app/models/lockable_user.rb
214
- - test/dummy/app/models/mang.rb
215
- - test/dummy/app/models/only_email_user.rb
216
- - test/dummy/app/models/scoped_user.rb
217
- - test/dummy/app/models/unconfirmable_user.rb
218
- - test/dummy/app/models/unregisterable_user.rb
219
- - test/dummy/app/models/user.rb
279
+ - test/dummy/app/models/concerns/favorite_color.rb
280
+ - test/dummy/app/mongoid/confirmable_user.rb
281
+ - test/dummy/app/mongoid/lockable_user.rb
282
+ - test/dummy/app/mongoid/mang.rb
283
+ - test/dummy/app/mongoid/only_email_user.rb
284
+ - test/dummy/app/mongoid/scoped_user.rb
285
+ - test/dummy/app/mongoid/unconfirmable_user.rb
286
+ - test/dummy/app/mongoid/unregisterable_user.rb
287
+ - test/dummy/app/mongoid/user.rb
220
288
  - test/dummy/app/views/layouts/application.html.erb
221
289
  - test/dummy/config.ru
222
290
  - test/dummy/config/application.rb
@@ -226,7 +294,6 @@ files:
226
294
  - test/dummy/config/environments/development.rb
227
295
  - test/dummy/config/environments/production.rb
228
296
  - test/dummy/config/environments/test.rb
229
- - test/dummy/config/initializers/assets.rb
230
297
  - test/dummy/config/initializers/backtrace_silencers.rb
231
298
  - test/dummy/config/initializers/cookies_serializer.rb
232
299
  - test/dummy/config/initializers/devise.rb
@@ -249,15 +316,24 @@ files:
249
316
  - test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb
250
317
  - test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb
251
318
  - test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb
319
+ - test/dummy/db/migrate/20190924101113_devise_token_auth_create_confirmable_users.rb
252
320
  - test/dummy/db/schema.rb
253
321
  - test/dummy/lib/migration_database_helper.rb
254
- - test/dummy/tmp/generators/app/views/devise/mailer/confirmation_instructions.html.erb
255
- - test/dummy/tmp/generators/app/views/devise/mailer/reset_password_instructions.html.erb
322
+ - test/dummy/tmp/generators/app/models/user.rb
323
+ - test/dummy/tmp/generators/config/initializers/devise_token_auth.rb
324
+ - test/dummy/tmp/generators/db/migrate/20220822003050_devise_token_auth_create_users.rb
256
325
  - test/factories/users.rb
326
+ - test/lib/devise_token_auth/blacklist_test.rb
327
+ - test/lib/devise_token_auth/rails/custom_routes_test.rb
328
+ - test/lib/devise_token_auth/rails/routes_test.rb
329
+ - test/lib/devise_token_auth/token_factory_test.rb
257
330
  - test/lib/devise_token_auth/url_test.rb
258
331
  - test/lib/generators/devise_token_auth/install_generator_test.rb
259
332
  - test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb
260
333
  - test/lib/generators/devise_token_auth/install_views_generator_test.rb
334
+ - test/models/concerns/mongoid_support_test.rb
335
+ - test/models/concerns/tokens_serialization_test.rb
336
+ - test/models/confirmable_user_test.rb
261
337
  - test/models/only_email_user_test.rb
262
338
  - test/models/user_test.rb
263
339
  - test/support/controllers/routes.rb
@@ -274,26 +350,35 @@ required_ruby_version: !ruby/object:Gem::Requirement
274
350
  requirements:
275
351
  - - ">="
276
352
  - !ruby/object:Gem::Version
277
- version: 2.2.0
353
+ version: 2.3.0
278
354
  required_rubygems_version: !ruby/object:Gem::Requirement
279
355
  requirements:
280
356
  - - ">="
281
357
  - !ruby/object:Gem::Version
282
358
  version: '0'
283
359
  requirements: []
284
- rubyforge_project:
285
- rubygems_version: 2.6.14.1
360
+ rubygems_version: 3.1.6
286
361
  signing_key:
287
362
  specification_version: 4
288
363
  summary: Token based authentication for rails. Uses Devise + OmniAuth.
289
364
  test_files:
290
- - test/dummy/app/models/only_email_user.rb
291
- - test/dummy/app/models/scoped_user.rb
292
- - test/dummy/app/models/mang.rb
293
- - test/dummy/app/models/unregisterable_user.rb
294
- - test/dummy/app/models/lockable_user.rb
295
- - test/dummy/app/models/unconfirmable_user.rb
296
- - test/dummy/app/models/user.rb
365
+ - test/dummy/app/mongoid/only_email_user.rb
366
+ - test/dummy/app/mongoid/scoped_user.rb
367
+ - test/dummy/app/mongoid/confirmable_user.rb
368
+ - test/dummy/app/mongoid/mang.rb
369
+ - test/dummy/app/mongoid/unregisterable_user.rb
370
+ - test/dummy/app/mongoid/lockable_user.rb
371
+ - test/dummy/app/mongoid/unconfirmable_user.rb
372
+ - test/dummy/app/mongoid/user.rb
373
+ - test/dummy/app/models/concerns/favorite_color.rb
374
+ - test/dummy/app/active_record/only_email_user.rb
375
+ - test/dummy/app/active_record/scoped_user.rb
376
+ - test/dummy/app/active_record/confirmable_user.rb
377
+ - test/dummy/app/active_record/mang.rb
378
+ - test/dummy/app/active_record/unregisterable_user.rb
379
+ - test/dummy/app/active_record/lockable_user.rb
380
+ - test/dummy/app/active_record/unconfirmable_user.rb
381
+ - test/dummy/app/active_record/user.rb
297
382
  - test/dummy/app/controllers/overrides/token_validations_controller.rb
298
383
  - test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb
299
384
  - test/dummy/app/controllers/overrides/passwords_controller.rb
@@ -328,7 +413,6 @@ test_files:
328
413
  - test/dummy/config/initializers/filter_parameter_logging.rb
329
414
  - test/dummy/config/initializers/session_store.rb
330
415
  - test/dummy/config/initializers/wrap_parameters.rb
331
- - test/dummy/config/initializers/assets.rb
332
416
  - test/dummy/config/initializers/cookies_serializer.rb
333
417
  - test/dummy/config/initializers/devise.rb
334
418
  - test/dummy/config/initializers/omniauth.rb
@@ -346,14 +430,23 @@ test_files:
346
430
  - test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb
347
431
  - test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb
348
432
  - test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb
349
- - test/dummy/tmp/generators/app/views/devise/mailer/confirmation_instructions.html.erb
350
- - test/dummy/tmp/generators/app/views/devise/mailer/reset_password_instructions.html.erb
433
+ - test/dummy/db/migrate/20190924101113_devise_token_auth_create_confirmable_users.rb
434
+ - test/dummy/tmp/generators/app/models/user.rb
435
+ - test/dummy/tmp/generators/config/initializers/devise_token_auth.rb
436
+ - test/dummy/tmp/generators/db/migrate/20220822003050_devise_token_auth_create_users.rb
351
437
  - test/dummy/README.rdoc
352
438
  - test/models/only_email_user_test.rb
439
+ - test/models/confirmable_user_test.rb
440
+ - test/models/concerns/mongoid_support_test.rb
441
+ - test/models/concerns/tokens_serialization_test.rb
353
442
  - test/models/user_test.rb
354
443
  - test/support/controllers/routes.rb
355
444
  - test/factories/users.rb
356
445
  - test/lib/devise_token_auth/url_test.rb
446
+ - test/lib/devise_token_auth/blacklist_test.rb
447
+ - test/lib/devise_token_auth/token_factory_test.rb
448
+ - test/lib/devise_token_auth/rails/custom_routes_test.rb
449
+ - test/lib/devise_token_auth/rails/routes_test.rb
357
450
  - test/lib/generators/devise_token_auth/install_generator_test.rb
358
451
  - test/lib/generators/devise_token_auth/install_views_generator_test.rb
359
452
  - test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb
@@ -1,198 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Use this hook to configure devise mailer, warden hooks and so forth.
4
- # Many of these configuration options can be set straight in your model.
5
- Devise.setup do |config|
6
- # The secret key used by Devise. Devise uses this key to generate
7
- # random tokens. Changing this key will render invalid all existing
8
- # confirmation, reset password and unlock tokens in the database.
9
- # config.secret_key = 'd029dbc7262359b4f9906ec029bae825981dee112d9a1425643719765c8fd4884f12a37add35607fa3fa2d6fa6945a0077d7fe0f10a67f8ee66d69e9cc6ac19b'
10
-
11
- # ==> Mailer Configuration
12
- # Configure the e-mail address which will be shown in Devise::Mailer,
13
- # note that it will be overwritten if you use your own mailer class
14
- # with default "from" parameter.
15
- config.mailer_sender = 'no-reply@example.com'
16
-
17
- # Configure the class responsible to send e-mails.
18
- # config.mailer = 'Devise::Mailer'
19
-
20
- # ==> ORM configuration
21
- # Load and configure the ORM. Supports :active_record (default) and
22
- # :mongoid (bson_ext recommended) by default. Other ORMs may be
23
- # available as additional gems.
24
- require 'devise/orm/active_record'
25
-
26
- # ==> Configuration for any authentication mechanism
27
- # Configure which keys are used when authenticating a user. The default is
28
- # just :email. You can configure it to use [:username, :subdomain], so for
29
- # authenticating a user, both parameters are required. Remember that those
30
- # parameters are used only when authenticating and not when retrieving from
31
- # session. If you need permissions, you should implement that in a before filter.
32
- # You can also supply a hash where the value is a boolean determining whether
33
- # or not authentication should be aborted when the value is not present.
34
- # config.authentication_keys = [ :email ]
35
-
36
- # Configure parameters from the request object used for authentication. Each entry
37
- # given should be a request method and it will automatically be passed to the
38
- # find_for_authentication method and considered in your model lookup. For instance,
39
- # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
40
- # The same considerations mentioned for authentication_keys also apply to request_keys.
41
- # config.request_keys = []
42
-
43
- # Configure which authentication keys should be case-insensitive.
44
- # These keys will be downcased upon creating or modifying a user and when used
45
- # to authenticate or find a user. Default is :email.
46
- config.case_insensitive_keys = [ :email ]
47
-
48
- # Configure which authentication keys should have whitespace stripped.
49
- # These keys will have whitespace before and after removed upon creating or
50
- # modifying a user and when used to authenticate or find a user. Default is :email.
51
- config.strip_whitespace_keys = [ :email ]
52
-
53
- # Tell if authentication through request.params is enabled. True by default.
54
- # It can be set to an array that will enable params authentication only for the
55
- # given strategies, for example, `config.params_authenticatable = [:database]` will
56
- # enable it only for database (email + password) authentication.
57
- # config.params_authenticatable = true
58
-
59
- # Tell if authentication through HTTP Auth is enabled. False by default.
60
- # It can be set to an array that will enable http authentication only for the
61
- # given strategies, for example, `config.http_authenticatable = [:database]` will
62
- # enable it only for database authentication. The supported strategies are:
63
- # :database = Support basic authentication with authentication key + password
64
- # config.http_authenticatable = false
65
-
66
- # If http headers should be returned for AJAX requests. True by default.
67
- # config.http_authenticatable_on_xhr = true
68
-
69
- # The realm used in Http Basic Authentication. 'Application' by default.
70
- # config.http_authentication_realm = 'Application'
71
-
72
- # It will change confirmation, password recovery and other workflows
73
- # to behave the same regardless if the e-mail provided was right or wrong.
74
- # Does not affect registerable.
75
- # config.paranoid = true
76
-
77
- # By default Devise will store the user in session. You can skip storage for
78
- # particular strategies by setting this option.
79
- # Notice that if you are skipping storage for all authentication paths, you
80
- # may want to disable generating routes to Devise's sessions controller by
81
- # passing skip: :sessions to `devise_for` in your config/routes.rb
82
- config.skip_session_storage = [:http_auth]
83
-
84
- # By default, Devise cleans up the CSRF token on authentication to
85
- # avoid CSRF token fixation attacks. This means that, when using AJAX
86
- # requests for sign in and sign up, you need to get a new CSRF token
87
- # from the server. You can disable this option at your own risk.
88
- # config.clean_up_csrf_token_on_authentication = true
89
-
90
- # ==> Configuration for :database_authenticatable
91
- # For bcrypt, this is the cost for hashing the password and defaults to 11. If
92
- # using other algorithms, it sets how many times you want the password to be hashed.
93
- #
94
- # Limiting the stretches to just one in testing will increase the performance of
95
- # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
96
- # a value less than 10 in other environments. Note that, for bcrypt (the default
97
- # algorithm), the cost increases exponentially with the number of stretches (e.g.
98
- # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
99
- config.stretches = Rails.env.test? ? 1 : 11
100
-
101
- # Setup a pepper to generate the encrypted password.
102
- # config.pepper = '8ff086600aff82d68ff1e00d23c99c821e66652ec8c2a5b48f58de4a56b325cb532f6db660cf58fc5ecb473b9d851be8cd1badff0a1053bc9dc045f78b6e6772'
103
-
104
- # ==> Configuration for :confirmable
105
- # A period that the user is allowed to access the website even without
106
- # confirming their account. For instance, if set to 2.days, the user will be
107
- # able to access the website for two days without confirming their account,
108
- # access will be blocked just in the third day. Default is 0.days, meaning
109
- # the user cannot access the website without confirming their account.
110
- # config.allow_unconfirmed_access_for = 2.days
111
-
112
- # A period that the user is allowed to confirm their account before their
113
- # token becomes invalid. For example, if set to 3.days, the user can confirm
114
- # their account within 3 days after the mail was sent, but on the fourth day
115
- # their account can't be confirmed with the token any more.
116
- # Default is nil, meaning there is no restriction on how long a user can take
117
- # before confirming their account.
118
- # config.confirm_within = 3.days
119
-
120
- # If true, requires any email changes to be confirmed (exactly the same way as
121
- # initial account confirmation) to be applied. Requires additional unconfirmed_email
122
- # db field (see migrations). Until confirmed, new email is stored in
123
- # unconfirmed_email column, and copied to email column on successful confirmation.
124
- config.reconfirmable = true
125
-
126
- # Defines which key will be used when confirming an account
127
- # config.confirmation_keys = [ :email ]
128
-
129
- # ==> Configuration for :rememberable
130
- # The time the user will be remembered without asking for credentials again.
131
- # config.remember_for = 2.weeks
132
-
133
- # If true, extends the user's remember period when remembered via cookie.
134
- # config.extend_remember_period = false
135
-
136
- # Options to be passed to the created cookie. For instance, you can set
137
- # secure: true in order to force SSL only cookies.
138
- # config.rememberable_options = {}
139
-
140
- # ==> Configuration for :validatable
141
- # Range for password length.
142
- config.password_length = 8..128
143
-
144
- # Email regex used to validate email formats. It simply asserts that
145
- # one (and only one) @ exists in the given string. This is mainly
146
- # to give user feedback and not to assert the e-mail validity.
147
- config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
148
-
149
- # ==> Configuration for :timeoutable
150
- # The time you want to timeout the user session without activity. After this
151
- # time the user will be asked for credentials again. Default is 30 minutes.
152
- # config.timeout_in = 30.minutes
153
-
154
- # If true, expires auth token on session timeout.
155
- # config.expire_auth_token_on_timeout = false
156
-
157
- # ==> Configuration for :lockable
158
- # Defines which strategy will be used to lock an account.
159
- # :failed_attempts = Locks an account after a number of failed attempts to sign in.
160
- # :none = No lock strategy. You should handle locking by yourself.
161
- # config.lock_strategy = :failed_attempts
162
-
163
- # Defines which key will be used when locking and unlocking an account
164
- # config.unlock_keys = [ :email ]
165
-
166
- # Defines which strategy will be used to unlock an account.
167
- # :email = Sends an unlock link to the user email
168
- # :time = Re-enables login after a certain amount of time (see :unlock_in below)
169
- # :both = Enables both strategies
170
- # :none = No unlock strategy. You should handle unlocking by yourself.
171
- # config.unlock_strategy = :both
172
-
173
- # Number of authentication tries before locking an account if lock_strategy
174
- # is failed attempts.
175
- # config.maximum_attempts = 20
176
-
177
- # Time interval to unlock the account if :time is enabled as unlock_strategy.
178
- # config.unlock_in = 1.hour
179
-
180
- # Warn on the last attempt before the account is locked.
181
- # config.last_attempt_warning = false
182
-
183
- # ==> Configuration for :recoverable
184
- #
185
- # Defines which key will be used when recovering the password for an account
186
- # config.reset_password_keys = [ :email ]
187
-
188
- # Time interval you can reset your password with a reset password key.
189
- # Don't put a too small interval or your users won't have the time to
190
- # change their passwords.
191
- config.reset_password_within = 6.hours
192
-
193
- # The default HTTP method used to sign out a resource. Default is :delete.
194
- config.sign_out_via = :delete
195
-
196
- # don't serialize tokens
197
- Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION << :tokens
198
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Be sure to restart your server when you modify this file.
4
-
5
- # Version of your assets, change this if you want to expire all your assets.
6
- Rails.application.config.assets.version = '1.0'
7
-
8
- # Precompile additional assets.
9
- # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
10
- # Rails.application.config.assets.precompile += %w( search.js )