devise_jwt_auth 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/devise_jwt_auth/application_controller.rb +11 -22
- data/app/controllers/devise_jwt_auth/concerns/resource_finder.rb +3 -7
- data/app/controllers/devise_jwt_auth/concerns/set_user_by_token.rb +22 -18
- data/app/controllers/devise_jwt_auth/confirmations_controller.rb +10 -19
- data/app/controllers/devise_jwt_auth/omniauth_callbacks_controller.rb +38 -46
- data/app/controllers/devise_jwt_auth/passwords_controller.rb +34 -36
- data/app/controllers/devise_jwt_auth/refresh_token_controller.rb +4 -1
- data/app/controllers/devise_jwt_auth/registrations_controller.rb +40 -21
- data/app/controllers/devise_jwt_auth/sessions_controller.rb +21 -21
- data/app/controllers/devise_jwt_auth/unlocks_controller.rb +5 -4
- data/app/models/devise_jwt_auth/concerns/active_record_support.rb +3 -0
- data/app/models/devise_jwt_auth/concerns/confirmable_support.rb +7 -14
- data/app/models/devise_jwt_auth/concerns/mongoid_support.rb +3 -0
- data/app/models/devise_jwt_auth/concerns/tokens_serialization.rb +4 -1
- data/app/models/devise_jwt_auth/concerns/user.rb +18 -11
- data/app/models/devise_jwt_auth/concerns/user_omniauth_callbacks.rb +11 -3
- data/app/validators/devise_jwt_auth_email_validator.rb +12 -2
- data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
- data/lib/devise_jwt_auth/blacklist.rb +3 -1
- data/lib/devise_jwt_auth/controllers/url_helpers.rb +1 -2
- data/lib/devise_jwt_auth/engine.rb +4 -4
- data/lib/devise_jwt_auth/rails/routes.rb +35 -24
- data/lib/devise_jwt_auth/token_factory.rb +3 -2
- data/lib/devise_jwt_auth/url.rb +2 -4
- data/lib/devise_jwt_auth/version.rb +1 -1
- data/lib/generators/devise_jwt_auth/USAGE +1 -1
- data/lib/generators/devise_jwt_auth/install_generator.rb +7 -6
- data/lib/generators/devise_jwt_auth/install_generator_helpers.rb +27 -6
- data/lib/generators/devise_jwt_auth/install_mongoid_generator.rb +3 -2
- data/lib/generators/devise_jwt_auth/templates/devise_jwt_auth.rb +6 -7
- data/lib/generators/devise_jwt_auth/templates/devise_jwt_auth_create_users.rb.erb +15 -11
- data/lib/generators/devise_jwt_auth/templates/user.rb.erb +2 -2
- data/test/controllers/custom/custom_confirmations_controller_test.rb +2 -2
- data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +1 -1
- data/test/controllers/custom/custom_passwords_controller_test.rb +8 -8
- data/test/controllers/custom/custom_refresh_token_controller_test.rb +2 -3
- data/test/controllers/custom/custom_registrations_controller_test.rb +2 -2
- data/test/controllers/demo_group_controller_test.rb +0 -24
- data/test/controllers/demo_mang_controller_test.rb +4 -224
- data/test/controllers/demo_user_controller_test.rb +6 -432
- data/test/controllers/devise_jwt_auth/confirmations_controller_test.rb +5 -5
- data/test/controllers/devise_jwt_auth/omniauth_callbacks_controller_test.rb +9 -10
- data/test/controllers/devise_jwt_auth/passwords_controller_test.rb +34 -35
- data/test/controllers/devise_jwt_auth/refresh_token_controller_test.rb +8 -12
- data/test/controllers/devise_jwt_auth/registrations_controller_test.rb +12 -26
- data/test/controllers/devise_jwt_auth/sessions_controller_test.rb +32 -34
- data/test/controllers/devise_jwt_auth/unlocks_controller_test.rb +2 -2
- data/test/controllers/overrides/confirmations_controller_test.rb +1 -1
- data/test/controllers/overrides/passwords_controller_test.rb +1 -6
- data/test/controllers/overrides/refresh_token_controller_test.rb +1 -2
- data/test/controllers/overrides/registrations_controller_test.rb +1 -1
- data/test/dummy/app/controllers/custom/refresh_token_controller.rb +2 -1
- data/test/dummy/app/controllers/custom/registrations_controller.rb +1 -1
- data/test/dummy/app/controllers/overrides/confirmations_controller.rb +3 -16
- data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +4 -4
- data/test/dummy/app/controllers/overrides/passwords_controller.rb +4 -16
- data/test/dummy/app/controllers/overrides/refresh_token_controller.rb +1 -1
- data/test/dummy/app/controllers/overrides/registrations_controller.rb +2 -2
- data/test/dummy/app/controllers/overrides/sessions_controller.rb +2 -2
- data/test/dummy/app/models/concerns/favorite_color.rb +11 -9
- data/test/dummy/config/application.rb +1 -0
- data/test/dummy/config/boot.rb +1 -1
- data/test/dummy/config/environments/development.rb +2 -2
- data/test/dummy/config/environments/test.rb +11 -7
- data/test/dummy/config/initializers/devise_jwt_auth.rb +1 -0
- data/test/dummy/config/initializers/figaro.rb +1 -1
- data/test/dummy/config/initializers/omniauth.rb +2 -2
- data/test/dummy/config/routes.rb +10 -8
- data/test/dummy/config.ru +2 -2
- data/test/dummy/db/migrate/20141222035835_devise_jwt_auth_create_only_email_users.rb +9 -9
- data/test/dummy/db/migrate/20190924101113_devise_jwt_auth_create_confirmable_users.rb +6 -5
- data/test/dummy/db/schema.rb +170 -170
- data/test/dummy/tmp/generators/app/models/user.rb +8 -0
- data/test/dummy/tmp/generators/config/initializers/devise_jwt_auth.rb +6 -7
- data/test/dummy/tmp/generators/db/migrate/{20200210193225_devise_jwt_auth_create_azpire_v1_human_resource_users.rb → 20220123023137_devise_jwt_auth_create_users.rb} +20 -17
- data/test/factories/users.rb +5 -3
- data/test/lib/devise_jwt_auth/blacklist_test.rb +2 -2
- data/test/lib/devise_jwt_auth/token_factory_test.rb +7 -7
- data/test/lib/generators/devise_jwt_auth/install_generator_test.rb +3 -20
- data/test/lib/generators/devise_jwt_auth/install_generator_with_namespace_test.rb +4 -21
- data/test/models/concerns/tokens_serialization_test.rb +68 -68
- data/test/models/user_test.rb +0 -38
- data/test/support/controllers/routes.rb +7 -5
- data/test/test_helper.rb +1 -1
- metadata +45 -71
- data/test/dummy/tmp/generators/app/models/azpire/v1/human_resource/user.rb +0 -9
data/test/dummy/db/schema.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is auto-generated from the current state of the database. Instead
|
2
4
|
# of editing this file, please use the migrations feature of Active Record to
|
3
5
|
# incrementally modify your database, and then regenerate this schema definition.
|
@@ -10,189 +12,187 @@
|
|
10
12
|
#
|
11
13
|
# It's strongly recommended that you check this file into your version control system.
|
12
14
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
14
|
-
|
15
|
-
|
16
|
-
t.string
|
17
|
-
t.string
|
18
|
-
t.string
|
19
|
-
t.
|
20
|
-
t.
|
21
|
-
t.
|
22
|
-
t.
|
23
|
-
t.
|
24
|
-
t.datetime
|
25
|
-
t.
|
26
|
-
t.string
|
27
|
-
t.string
|
28
|
-
t.string
|
29
|
-
t.string
|
30
|
-
t.
|
31
|
-
t.
|
32
|
-
t.datetime
|
33
|
-
t.
|
34
|
-
t.index [
|
35
|
-
t.index [
|
36
|
-
t.index [
|
37
|
-
t.index ["uid", "provider"], name: "index_confirmable_users_on_uid_and_provider", unique: true
|
15
|
+
ActiveRecord::Schema.define(version: 20_190_924_101_113) do
|
16
|
+
create_table 'confirmable_users', force: :cascade do |t|
|
17
|
+
t.string 'provider', default: 'email', null: false
|
18
|
+
t.string 'uid', default: '', null: false
|
19
|
+
t.string 'encrypted_password', default: '', null: false
|
20
|
+
t.string 'reset_password_token'
|
21
|
+
t.datetime 'reset_password_sent_at'
|
22
|
+
t.boolean 'allow_password_change', default: false
|
23
|
+
t.datetime 'remember_created_at'
|
24
|
+
t.string 'confirmation_token'
|
25
|
+
t.datetime 'confirmed_at'
|
26
|
+
t.datetime 'confirmation_sent_at'
|
27
|
+
t.string 'unconfirmed_email'
|
28
|
+
t.string 'name'
|
29
|
+
t.string 'nickname'
|
30
|
+
t.string 'image'
|
31
|
+
t.string 'email'
|
32
|
+
t.text 'tokens'
|
33
|
+
t.datetime 'created_at', null: false
|
34
|
+
t.datetime 'updated_at', null: false
|
35
|
+
t.index ['confirmation_token'], name: 'index_confirmable_users_on_confirmation_token', unique: true
|
36
|
+
t.index ['email'], name: 'index_confirmable_users_on_email', unique: true
|
37
|
+
t.index ['reset_password_token'], name: 'index_confirmable_users_on_reset_password_token', unique: true
|
38
|
+
t.index ['uid', 'provider'], name: 'index_confirmable_users_on_uid_and_provider', unique: true
|
38
39
|
end
|
39
40
|
|
40
|
-
create_table
|
41
|
-
t.string
|
42
|
-
t.string
|
43
|
-
t.string
|
44
|
-
t.integer
|
45
|
-
t.string
|
46
|
-
t.datetime
|
47
|
-
t.string
|
48
|
-
t.string
|
49
|
-
t.string
|
50
|
-
t.string
|
51
|
-
t.text
|
52
|
-
t.datetime
|
53
|
-
t.datetime
|
54
|
-
t.index [
|
55
|
-
t.index [
|
56
|
-
t.index [
|
41
|
+
create_table 'lockable_users', force: :cascade do |t|
|
42
|
+
t.string 'provider', null: false
|
43
|
+
t.string 'uid', default: '', null: false
|
44
|
+
t.string 'encrypted_password', default: '', null: false
|
45
|
+
t.integer 'failed_attempts', default: 0, null: false
|
46
|
+
t.string 'unlock_token'
|
47
|
+
t.datetime 'locked_at'
|
48
|
+
t.string 'name'
|
49
|
+
t.string 'nickname'
|
50
|
+
t.string 'image'
|
51
|
+
t.string 'email'
|
52
|
+
t.text 'tokens'
|
53
|
+
t.datetime 'created_at'
|
54
|
+
t.datetime 'updated_at'
|
55
|
+
t.index ['email'], name: 'index_lockable_users_on_email'
|
56
|
+
t.index ['uid', 'provider'], name: 'index_lockable_users_on_uid_and_provider', unique: true
|
57
|
+
t.index ['unlock_token'], name: 'index_lockable_users_on_unlock_token', unique: true
|
57
58
|
end
|
58
59
|
|
59
|
-
create_table
|
60
|
-
t.string
|
61
|
-
t.string
|
62
|
-
t.string
|
63
|
-
t.datetime
|
64
|
-
t.string
|
65
|
-
t.boolean
|
66
|
-
t.datetime
|
67
|
-
t.string
|
68
|
-
t.datetime
|
69
|
-
t.datetime
|
70
|
-
t.string
|
71
|
-
t.string
|
72
|
-
t.string
|
73
|
-
t.string
|
74
|
-
t.string
|
75
|
-
t.string
|
76
|
-
t.text
|
77
|
-
t.datetime
|
78
|
-
t.datetime
|
79
|
-
t.string
|
80
|
-
t.index [
|
81
|
-
t.index [
|
82
|
-
t.index [
|
83
|
-
t.index [
|
60
|
+
create_table 'mangs', force: :cascade do |t|
|
61
|
+
t.string 'email'
|
62
|
+
t.string 'encrypted_password', default: '', null: false
|
63
|
+
t.string 'reset_password_token'
|
64
|
+
t.datetime 'reset_password_sent_at'
|
65
|
+
t.string 'reset_password_redirect_url'
|
66
|
+
t.boolean 'allow_password_change', default: false
|
67
|
+
t.datetime 'remember_created_at'
|
68
|
+
t.string 'confirmation_token'
|
69
|
+
t.datetime 'confirmed_at'
|
70
|
+
t.datetime 'confirmation_sent_at'
|
71
|
+
t.string 'unconfirmed_email'
|
72
|
+
t.string 'name'
|
73
|
+
t.string 'nickname'
|
74
|
+
t.string 'image'
|
75
|
+
t.string 'provider'
|
76
|
+
t.string 'uid', default: '', null: false
|
77
|
+
t.text 'tokens'
|
78
|
+
t.datetime 'created_at'
|
79
|
+
t.datetime 'updated_at'
|
80
|
+
t.string 'favorite_color'
|
81
|
+
t.index ['confirmation_token'], name: 'index_mangs_on_confirmation_token', unique: true
|
82
|
+
t.index ['email'], name: 'index_mangs_on_email'
|
83
|
+
t.index ['reset_password_token'], name: 'index_mangs_on_reset_password_token', unique: true
|
84
|
+
t.index ['uid', 'provider'], name: 'index_mangs_on_uid_and_provider', unique: true
|
84
85
|
end
|
85
86
|
|
86
|
-
create_table
|
87
|
-
t.string
|
88
|
-
t.string
|
89
|
-
t.string
|
90
|
-
t.string
|
91
|
-
t.string
|
92
|
-
t.string
|
93
|
-
t.string
|
94
|
-
t.text
|
95
|
-
t.datetime
|
96
|
-
t.datetime
|
97
|
-
t.index [
|
98
|
-
t.index [
|
87
|
+
create_table 'only_email_users', force: :cascade do |t|
|
88
|
+
t.string 'provider', null: false
|
89
|
+
t.string 'uid', default: '', null: false
|
90
|
+
t.string 'encrypted_password', default: '', null: false
|
91
|
+
t.string 'name'
|
92
|
+
t.string 'nickname'
|
93
|
+
t.string 'image'
|
94
|
+
t.string 'email'
|
95
|
+
t.text 'tokens'
|
96
|
+
t.datetime 'created_at'
|
97
|
+
t.datetime 'updated_at'
|
98
|
+
t.index ['email'], name: 'index_only_email_users_on_email'
|
99
|
+
t.index ['uid', 'provider'], name: 'index_only_email_users_on_uid_and_provider', unique: true
|
99
100
|
end
|
100
101
|
|
101
|
-
create_table
|
102
|
-
t.string
|
103
|
-
t.string
|
104
|
-
t.string
|
105
|
-
t.string
|
106
|
-
t.datetime
|
107
|
-
t.boolean
|
108
|
-
t.datetime
|
109
|
-
t.string
|
110
|
-
t.datetime
|
111
|
-
t.datetime
|
112
|
-
t.string
|
113
|
-
t.string
|
114
|
-
t.string
|
115
|
-
t.string
|
116
|
-
t.string
|
117
|
-
t.text
|
118
|
-
t.datetime
|
119
|
-
t.datetime
|
120
|
-
t.index [
|
121
|
-
t.index [
|
122
|
-
t.index [
|
102
|
+
create_table 'scoped_users', force: :cascade do |t|
|
103
|
+
t.string 'provider', null: false
|
104
|
+
t.string 'uid', default: '', null: false
|
105
|
+
t.string 'encrypted_password', default: '', null: false
|
106
|
+
t.string 'reset_password_token'
|
107
|
+
t.datetime 'reset_password_sent_at'
|
108
|
+
t.boolean 'allow_password_change', default: false
|
109
|
+
t.datetime 'remember_created_at'
|
110
|
+
t.string 'confirmation_token'
|
111
|
+
t.datetime 'confirmed_at'
|
112
|
+
t.datetime 'confirmation_sent_at'
|
113
|
+
t.string 'unconfirmed_email'
|
114
|
+
t.string 'name'
|
115
|
+
t.string 'nickname'
|
116
|
+
t.string 'image'
|
117
|
+
t.string 'email'
|
118
|
+
t.text 'tokens'
|
119
|
+
t.datetime 'created_at'
|
120
|
+
t.datetime 'updated_at'
|
121
|
+
t.index ['email'], name: 'index_scoped_users_on_email'
|
122
|
+
t.index ['reset_password_token'], name: 'index_scoped_users_on_reset_password_token', unique: true
|
123
|
+
t.index ['uid', 'provider'], name: 'index_scoped_users_on_uid_and_provider', unique: true
|
123
124
|
end
|
124
125
|
|
125
|
-
create_table
|
126
|
-
t.string
|
127
|
-
t.string
|
128
|
-
t.string
|
129
|
-
t.string
|
130
|
-
t.datetime
|
131
|
-
t.boolean
|
132
|
-
t.datetime
|
133
|
-
t.string
|
134
|
-
t.string
|
135
|
-
t.string
|
136
|
-
t.string
|
137
|
-
t.text
|
138
|
-
t.datetime
|
139
|
-
t.datetime
|
140
|
-
t.index [
|
141
|
-
t.index [
|
142
|
-
t.index [
|
126
|
+
create_table 'unconfirmable_users', force: :cascade do |t|
|
127
|
+
t.string 'provider', null: false
|
128
|
+
t.string 'uid', default: '', null: false
|
129
|
+
t.string 'encrypted_password', default: '', null: false
|
130
|
+
t.string 'reset_password_token'
|
131
|
+
t.datetime 'reset_password_sent_at'
|
132
|
+
t.boolean 'allow_password_change', default: false
|
133
|
+
t.datetime 'remember_created_at'
|
134
|
+
t.string 'name'
|
135
|
+
t.string 'nickname'
|
136
|
+
t.string 'image'
|
137
|
+
t.string 'email'
|
138
|
+
t.text 'tokens'
|
139
|
+
t.datetime 'created_at'
|
140
|
+
t.datetime 'updated_at'
|
141
|
+
t.index ['email'], name: 'index_unconfirmable_users_on_email'
|
142
|
+
t.index ['reset_password_token'], name: 'index_unconfirmable_users_on_reset_password_token', unique: true
|
143
|
+
t.index ['uid', 'provider'], name: 'index_unconfirmable_users_on_uid_and_provider', unique: true
|
143
144
|
end
|
144
145
|
|
145
|
-
create_table
|
146
|
-
t.string
|
147
|
-
t.string
|
148
|
-
t.string
|
149
|
-
t.string
|
150
|
-
t.datetime
|
151
|
-
t.boolean
|
152
|
-
t.datetime
|
153
|
-
t.string
|
154
|
-
t.datetime
|
155
|
-
t.datetime
|
156
|
-
t.string
|
157
|
-
t.string
|
158
|
-
t.string
|
159
|
-
t.string
|
160
|
-
t.string
|
161
|
-
t.text
|
162
|
-
t.datetime
|
163
|
-
t.datetime
|
164
|
-
t.index [
|
165
|
-
t.index [
|
166
|
-
t.index [
|
146
|
+
create_table 'unregisterable_users', force: :cascade do |t|
|
147
|
+
t.string 'provider', null: false
|
148
|
+
t.string 'uid', default: '', null: false
|
149
|
+
t.string 'encrypted_password', default: '', null: false
|
150
|
+
t.string 'reset_password_token'
|
151
|
+
t.datetime 'reset_password_sent_at'
|
152
|
+
t.boolean 'allow_password_change', default: false
|
153
|
+
t.datetime 'remember_created_at'
|
154
|
+
t.string 'confirmation_token'
|
155
|
+
t.datetime 'confirmed_at'
|
156
|
+
t.datetime 'confirmation_sent_at'
|
157
|
+
t.string 'unconfirmed_email'
|
158
|
+
t.string 'name'
|
159
|
+
t.string 'nickname'
|
160
|
+
t.string 'image'
|
161
|
+
t.string 'email'
|
162
|
+
t.text 'tokens'
|
163
|
+
t.datetime 'created_at'
|
164
|
+
t.datetime 'updated_at'
|
165
|
+
t.index ['email'], name: 'index_unregisterable_users_on_email'
|
166
|
+
t.index ['reset_password_token'], name: 'index_unregisterable_users_on_reset_password_token', unique: true
|
167
|
+
t.index ['uid', 'provider'], name: 'index_unregisterable_users_on_uid_and_provider', unique: true
|
167
168
|
end
|
168
169
|
|
169
|
-
create_table
|
170
|
-
t.string
|
171
|
-
t.string
|
172
|
-
t.string
|
173
|
-
t.datetime
|
174
|
-
t.string
|
175
|
-
t.boolean
|
176
|
-
t.datetime
|
177
|
-
t.string
|
178
|
-
t.datetime
|
179
|
-
t.datetime
|
180
|
-
t.string
|
181
|
-
t.string
|
182
|
-
t.string
|
183
|
-
t.string
|
184
|
-
t.string
|
185
|
-
t.string
|
186
|
-
t.text
|
187
|
-
t.datetime
|
188
|
-
t.datetime
|
189
|
-
t.integer
|
190
|
-
t.string
|
191
|
-
t.index [
|
192
|
-
t.index [
|
193
|
-
t.index [
|
194
|
-
t.index [
|
195
|
-
t.index [
|
170
|
+
create_table 'users', force: :cascade do |t|
|
171
|
+
t.string 'email'
|
172
|
+
t.string 'encrypted_password', default: '', null: false
|
173
|
+
t.string 'reset_password_token'
|
174
|
+
t.datetime 'reset_password_sent_at'
|
175
|
+
t.string 'reset_password_redirect_url'
|
176
|
+
t.boolean 'allow_password_change', default: false
|
177
|
+
t.datetime 'remember_created_at'
|
178
|
+
t.string 'confirmation_token'
|
179
|
+
t.datetime 'confirmed_at'
|
180
|
+
t.datetime 'confirmation_sent_at'
|
181
|
+
t.string 'unconfirmed_email'
|
182
|
+
t.string 'name'
|
183
|
+
t.string 'nickname'
|
184
|
+
t.string 'image'
|
185
|
+
t.string 'provider'
|
186
|
+
t.string 'uid', default: '', null: false
|
187
|
+
t.text 'tokens'
|
188
|
+
t.datetime 'created_at'
|
189
|
+
t.datetime 'updated_at'
|
190
|
+
t.integer 'operating_thetan'
|
191
|
+
t.string 'favorite_color'
|
192
|
+
t.index ['confirmation_token'], name: 'index_users_on_confirmation_token', unique: true
|
193
|
+
t.index ['email'], name: 'index_users_on_email'
|
194
|
+
t.index ['nickname'], name: 'index_users_on_nickname', unique: true
|
195
|
+
t.index ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true
|
196
|
+
t.index ['uid', 'provider'], name: 'index_users_on_uid_and_provider', unique: true
|
196
197
|
end
|
197
|
-
|
198
198
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
# Include default devise modules.
|
3
|
+
devise :database_authenticatable, :registerable,
|
4
|
+
:recoverable, :rememberable, :trackable, :validatable,
|
5
|
+
:confirmable, :omniauthable
|
6
|
+
include DeviseJwtAuth::Concerns::User
|
7
|
+
def whatever; puts 'whatever'; end
|
8
|
+
end
|
@@ -6,7 +6,7 @@ DeviseJwtAuth.setup do |config|
|
|
6
6
|
# use the HTTP only refresh cookie that is sent during the authentication
|
7
7
|
# process and make refresh token requests.
|
8
8
|
# config.send_new_access_token_on_each_request = false
|
9
|
-
|
9
|
+
|
10
10
|
# By default, refresh token HTTP Only cookies last for 2 weeks. These tokens
|
11
11
|
# are used for requesting shorter-lived acccess tokens.
|
12
12
|
# config.refresh_token_lifespan = 2.weeks
|
@@ -29,13 +29,13 @@ DeviseJwtAuth.setup do |config|
|
|
29
29
|
# config.access_token_name = 'access-token'
|
30
30
|
|
31
31
|
# This is the refresh token encryption key. You should set this in an
|
32
|
-
# environment variable or secret key base that isn't
|
32
|
+
# environment variable or secret key base that isn't stored in a repository.
|
33
33
|
# Also, its a good idea to NOT use the same key for access tokens.
|
34
34
|
config.refresh_token_encryption_key = 'your-refresh-token-secret-key-here'
|
35
|
-
|
36
|
-
# This is the
|
37
|
-
# environment variable or secret key base that isn't
|
38
|
-
# Also, its a good idea to NOT use the same key for
|
35
|
+
|
36
|
+
# This is the access token encryption key. You should set this in an
|
37
|
+
# environment variable or secret key base that isn't stored in a repository.
|
38
|
+
# Also, its a good idea to NOT use the same key for refresh tokens.
|
39
39
|
config.access_token_encryption_key = 'your-access-token-secret-key-here'
|
40
40
|
|
41
41
|
# This route will be the prefix for all oauth2 redirect callbacks. For
|
@@ -70,5 +70,4 @@ DeviseJwtAuth.setup do |config|
|
|
70
70
|
# config.update_token_version_after_password_reset = true
|
71
71
|
# config.bypass_sign_in = true
|
72
72
|
# config.require_client_password_reset_token = false
|
73
|
-
|
74
73
|
end
|
@@ -1,13 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class
|
3
|
+
class DeviseJwtAuthCreateUsers < ActiveRecord::Migration[6.1]
|
4
4
|
def change
|
5
|
-
|
6
|
-
create_table(:azpire_v1_human_resource_users) do |t|
|
5
|
+
create_table(:users) do |t|
|
7
6
|
## Required
|
8
7
|
t.string :provider, null: false, default: 'email'
|
9
8
|
t.string :uid, null: false, default: ''
|
10
9
|
|
10
|
+
## User Info
|
11
|
+
t.string :name
|
12
|
+
t.string :nickname
|
13
|
+
t.string :image
|
14
|
+
t.string :email
|
15
|
+
|
11
16
|
## Database authenticatable
|
12
17
|
t.string :encrypted_password, null: false, default: ''
|
13
18
|
|
@@ -19,6 +24,13 @@ class DeviseJwtAuthCreateAzpireV1HumanResourceUsers < ActiveRecord::Migration[6.
|
|
19
24
|
## Rememberable
|
20
25
|
t.datetime :remember_created_at
|
21
26
|
|
27
|
+
## Trackable
|
28
|
+
# t.integer :sign_in_count, default: 0, null: false
|
29
|
+
# t.datetime :current_sign_in_at
|
30
|
+
# t.datetime :last_sign_in_at
|
31
|
+
# t.string :current_sign_in_ip
|
32
|
+
# t.string :last_sign_in_ip
|
33
|
+
|
22
34
|
## Confirmable
|
23
35
|
t.string :confirmation_token
|
24
36
|
t.datetime :confirmed_at
|
@@ -30,22 +42,13 @@ class DeviseJwtAuthCreateAzpireV1HumanResourceUsers < ActiveRecord::Migration[6.
|
|
30
42
|
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
31
43
|
# t.datetime :locked_at
|
32
44
|
|
33
|
-
## User Info
|
34
|
-
t.string :name
|
35
|
-
t.string :nickname
|
36
|
-
t.string :image
|
37
|
-
t.string :email
|
38
|
-
|
39
|
-
## Tokens
|
40
|
-
t.text :tokens
|
41
|
-
|
42
45
|
t.timestamps
|
43
46
|
end
|
44
47
|
|
45
|
-
add_index :
|
46
|
-
add_index :
|
47
|
-
add_index :
|
48
|
-
add_index :
|
49
|
-
# add_index :
|
48
|
+
add_index :users, :email, unique: true
|
49
|
+
add_index :users, [:uid, :provider], unique: true
|
50
|
+
add_index :users, :reset_password_token, unique: true
|
51
|
+
add_index :users, :confirmation_token, unique: true
|
52
|
+
# add_index :users, :unlock_token, unique: true
|
50
53
|
end
|
51
54
|
end
|
data/test/factories/users.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
FactoryBot.define do
|
2
4
|
factory :user do
|
3
5
|
email { Faker::Internet.unique.safe_email }
|
@@ -13,13 +15,13 @@ FactoryBot.define do
|
|
13
15
|
end
|
14
16
|
|
15
17
|
trait :confirmed do
|
16
|
-
after(:create
|
18
|
+
after(:create, &:confirm)
|
17
19
|
end
|
18
20
|
|
19
21
|
# confirmation period is expired
|
20
22
|
trait :unconfirmed do
|
21
23
|
after(:create) do |user, evaluator|
|
22
|
-
user.update_attribute(:confirmation_sent_at, evaluator.allow_unconfirmed_period - 1.day
|
24
|
+
user.update_attribute(:confirmation_sent_at, evaluator.allow_unconfirmed_period - 1.day)
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
@@ -29,7 +31,7 @@ FactoryBot.define do
|
|
29
31
|
end
|
30
32
|
|
31
33
|
trait :locked do
|
32
|
-
after(:create
|
34
|
+
after(:create, &:lock_access!)
|
33
35
|
end
|
34
36
|
|
35
37
|
factory :lockable_user, class: 'LockableUser'
|
@@ -3,9 +3,9 @@
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
5
|
class DeviseJwtAuth::BlacklistTest < ActiveSupport::TestCase
|
6
|
-
describe Devise::Models::Authenticatable::
|
6
|
+
describe Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION do
|
7
7
|
test 'should include :tokens' do
|
8
|
-
assert Devise::Models::Authenticatable::
|
8
|
+
assert Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION.include?(:tokens)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -5,15 +5,15 @@ require 'test_helper'
|
|
5
5
|
class DeviseJwtAuth::TokenFactoryTest < ActiveSupport::TestCase
|
6
6
|
describe 'TokenFactory module' do
|
7
7
|
let(:tf) { DeviseJwtAuth::TokenFactory }
|
8
|
-
let(:token_regexp) {
|
9
|
-
|
8
|
+
let(:token_regexp) { %r{^[A-Za-z0-9\-_=]+\.[A-Za-z0-9\-_=]+\.?[A-Za-z0-9\-_.+/=]*$} }
|
9
|
+
|
10
10
|
it 'should be defined' do
|
11
11
|
assert_equal(tf.present?, true)
|
12
12
|
assert_kind_of(Module, tf)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
describe 'interface' do
|
16
|
-
let(:payload) { { foo: 'test'} }
|
16
|
+
let(:payload) { { foo: 'test' } }
|
17
17
|
let(:future_exp) { (Time.zone.now + 1.hour).to_i }
|
18
18
|
let(:past_exp) { (Time.zone.now - 1.hour).to_i }
|
19
19
|
|
@@ -44,13 +44,13 @@ class DeviseJwtAuth::TokenFactoryTest < ActiveSupport::TestCase
|
|
44
44
|
result = tf.decode_refresh_token(token)
|
45
45
|
assert result['exp'] == future_exp
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
it 'invalidates expired token' do
|
49
49
|
token = tf.create_refresh_token(payload.merge(exp: past_exp))
|
50
50
|
result = tf.decode_refresh_token(token)
|
51
51
|
assert_nil result['exp']
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
it 'invalidates bogus token' do
|
55
55
|
result = tf.decode_refresh_token('bogus token')
|
56
56
|
assert_empty result
|
@@ -91,7 +91,7 @@ class DeviseJwtAuth::TokenFactoryTest < ActiveSupport::TestCase
|
|
91
91
|
result = tf.decode_access_token(token)
|
92
92
|
assert_nil result['exp']
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
it 'invalidates bogus token' do
|
96
96
|
result = tf.decode_access_token('bogus token')
|
97
97
|
assert_empty result
|
@@ -44,17 +44,6 @@ module DeviseJwtAuth
|
|
44
44
|
assert_migration 'db/migrate/devise_jwt_auth_create_users.rb'
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
48
|
-
=begin
|
49
|
-
test 'add primary key type with rails 5 when specified in rails generator' do
|
50
|
-
run_generator %w[--primary_key_type=uuid --force]
|
51
|
-
if Rails::VERSION::MAJOR >= 5
|
52
|
-
assert_migration 'db/migrate/devise_jwt_auth_create_users.rb', /create_table\(:users, id: :uuid\) do/
|
53
|
-
else
|
54
|
-
assert_migration 'db/migrate/devise_jwt_auth_create_users.rb', /create_table\(:users\) do/
|
55
|
-
end
|
56
|
-
end
|
57
|
-
=end
|
58
47
|
end
|
59
48
|
end
|
60
49
|
|
@@ -72,15 +61,12 @@ module DeviseJwtAuth
|
|
72
61
|
case DEVISE_JWT_AUTH_ORM
|
73
62
|
when :active_record
|
74
63
|
# account for rails version 5
|
75
|
-
active_record_needle =
|
64
|
+
active_record_needle = Rails::VERSION::MAJOR == 5 ? 'ApplicationRecord' : 'ActiveRecord::Base'
|
76
65
|
|
77
66
|
@f = File.open(@fname, 'w') do |f|
|
78
67
|
f.write <<-RUBY
|
79
68
|
class User < #{active_record_needle}
|
80
|
-
|
81
|
-
def whatever
|
82
|
-
puts 'whatever'
|
83
|
-
end
|
69
|
+
def whatever; puts 'whatever'; end
|
84
70
|
end
|
85
71
|
RUBY
|
86
72
|
end
|
@@ -88,10 +74,7 @@ module DeviseJwtAuth
|
|
88
74
|
@f = File.open(@fname, 'w') do |f|
|
89
75
|
f.write <<-'RUBY'
|
90
76
|
class User
|
91
|
-
|
92
|
-
def whatever
|
93
|
-
puts 'whatever'
|
94
|
-
end
|
77
|
+
def whatever; puts 'whatever'; end
|
95
78
|
end
|
96
79
|
RUBY
|
97
80
|
end
|