devise-token_authenticatable 0.1.0 → 0.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +4 -3
- data/README.md +4 -0
- data/devise-token_authenticatable.gemspec +7 -9
- data/lib/devise/token_authenticatable/model.rb +3 -3
- data/lib/devise/token_authenticatable/version.rb +1 -1
- data/spec/models/devise/token_authenticatable/model_spec.rb +4 -4
- data/spec/requests/devise/token_authenticatable/strategy_spec.rb +147 -75
- data/spec/spec_helper.rb +6 -2
- data/spec/support/rails_app/app/controllers/admins_controller.rb +1 -1
- data/spec/support/rails_app/app/controllers/application_controller.rb +2 -2
- data/spec/support/rails_app/app/controllers/home_controller.rb +1 -1
- data/spec/support/rails_app/app/controllers/users_controller.rb +6 -5
- data/spec/support/rails_app/app/mailers/users/mailer.rb +4 -4
- data/spec/support/rails_app/app/models/admin.rb +4 -4
- data/spec/support/rails_app/config/application.rb +13 -0
- data/spec/support/rails_app/config/boot.rb +3 -0
- data/spec/support/rails_app/config/environment.rb +5 -0
- data/spec/support/rails_app/config/initializers/secret_token.rb +5 -2
- data/spec/support/rails_app/config/initializers/session_store.rb +1 -0
- data/spec/support/rails_app/config/routes.rb +56 -42
- metadata +54 -97
- data/spec/support/rails_app.rb +0 -19
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: efc7e438a5cbc91099707f3555ee5df174ba2bcf
|
4
|
+
data.tar.gz: 4056376f20e6844b5c2609d1dbd481a727e530e7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a3f9bb7ef09ee19689653736907a3db289e8ec562422d3a89534ce1af6ab7a96b60b19ff020b7039995ac1c3c382a279c11cf6f717aa5eafa662f1a4bc604e2a
|
7
|
+
data.tar.gz: bf3dda8ca8db55cbbdc13babfadd9bf74a1b9c315803fbdda9f2add45b58a9c4dfc5810521b2f7d25acdd3a99df34ea9ad1d45ac51f94d56977dff74573a930f
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -20,6 +20,10 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
$ gem install devise-token_authenticatable
|
22
22
|
|
23
|
+
### Users of Devise earlier than 3.3.0
|
24
|
+
|
25
|
+
Please, use version 0.1.0 of this gem. All later versions do not support Devise < 3.3.0.
|
26
|
+
|
23
27
|
## Usage
|
24
28
|
|
25
29
|
Add `:token_authenticatable` to your devise model:
|
@@ -22,16 +22,14 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
24
|
|
25
|
-
spec.add_dependency "devise",
|
25
|
+
spec.add_dependency "devise", "~> 3.3.0"
|
26
26
|
|
27
|
-
spec.add_development_dependency "
|
28
|
-
spec.add_development_dependency "
|
29
|
-
spec.add_development_dependency "
|
30
|
-
spec.add_development_dependency "
|
31
|
-
spec.add_development_dependency "
|
32
|
-
spec.add_development_dependency "
|
33
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
34
|
-
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rails", "~> 4.1.0"
|
28
|
+
spec.add_development_dependency "rspec-rails", "~> 3.0.2"
|
29
|
+
spec.add_development_dependency "pry", "~> 0.10.0"
|
30
|
+
spec.add_development_dependency "factory_girl_rails", "~> 4.4.0"
|
31
|
+
spec.add_development_dependency "timecop", "~> 0.7.0"
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
35
33
|
|
36
34
|
# Fix database connection with sqlite3 and jruby
|
37
35
|
if RUBY_ENGINE == 'ruby'
|
@@ -49,7 +49,7 @@ module Devise
|
|
49
49
|
# Generate new authentication token and save the record.
|
50
50
|
def reset_authentication_token!
|
51
51
|
reset_authentication_token
|
52
|
-
save(:
|
52
|
+
save(validate: false)
|
53
53
|
end
|
54
54
|
|
55
55
|
# Generate authentication token unless already exists.
|
@@ -72,14 +72,14 @@ module Devise
|
|
72
72
|
|
73
73
|
module ClassMethods
|
74
74
|
def find_for_token_authentication(conditions)
|
75
|
-
find_for_authentication(:
|
75
|
+
find_for_authentication(authentication_token: conditions[Devise::TokenAuthenticatable.token_authentication_key])
|
76
76
|
end
|
77
77
|
|
78
78
|
# Generate a token checking if one does not already exist in the database.
|
79
79
|
def authentication_token
|
80
80
|
loop do
|
81
81
|
token = Devise.friendly_token
|
82
|
-
break token unless to_adapter.find_first({ :
|
82
|
+
break token unless to_adapter.find_first({ authentication_token: token })
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
##
|
4
|
-
# If a model that is
|
4
|
+
# If a model that is token authenticatable should be tested with
|
5
5
|
# this shared example the corresponding factory has to provide a trait
|
6
6
|
# +:with_authentication_token+ that sets the attribute +authentication_token+.
|
7
7
|
#
|
8
|
-
# See spec/factories/
|
8
|
+
# See spec/factories/user.rb for an example.
|
9
9
|
#
|
10
|
-
shared_examples "
|
10
|
+
shared_examples "token authenticatable" do
|
11
11
|
|
12
12
|
context "instance methods" do
|
13
13
|
|
@@ -75,5 +75,5 @@ shared_examples "plain token authenticatable" do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
describe User do
|
78
|
-
it_behaves_like "
|
78
|
+
it_behaves_like "token authenticatable"
|
79
79
|
end
|
@@ -7,15 +7,15 @@ describe Devise::Strategies::TokenAuthenticatable do
|
|
7
7
|
context "through params" do
|
8
8
|
|
9
9
|
it "should be a success" do
|
10
|
-
swap Devise::TokenAuthenticatable, :
|
10
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
11
11
|
sign_in_as_new_user_with_token
|
12
12
|
|
13
|
-
response.
|
13
|
+
expect(response).to be_success
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should set the auth_token parameter" do
|
18
|
-
swap Devise::TokenAuthenticatable, :
|
18
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
19
19
|
user = sign_in_as_new_user_with_token
|
20
20
|
|
21
21
|
expect(@request.fullpath).to eq("/users?secret_token=#{user.authentication_token}")
|
@@ -23,7 +23,7 @@ describe Devise::Strategies::TokenAuthenticatable do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should authenticate user" do
|
26
|
-
swap Devise::TokenAuthenticatable, :
|
26
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
27
27
|
sign_in_as_new_user_with_token
|
28
28
|
|
29
29
|
expect(warden).to be_authenticated(:user)
|
@@ -34,23 +34,23 @@ describe Devise::Strategies::TokenAuthenticatable do
|
|
34
34
|
let(:user) { create(:user, :with_authentication_token) }
|
35
35
|
|
36
36
|
it 'should be a success' do
|
37
|
-
swap Devise::TokenAuthenticatable, :
|
37
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
38
38
|
post exhibit_user_path(user), Devise::TokenAuthenticatable.token_authentication_key => user.authentication_token, user: { some: "data" }
|
39
39
|
|
40
|
-
response.
|
40
|
+
expect(response).to be_success
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'should return proper data' do
|
45
|
-
swap Devise::TokenAuthenticatable, :
|
45
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
46
46
|
post exhibit_user_path(user), Devise::TokenAuthenticatable.token_authentication_key => user.authentication_token, user: { some: "data" }
|
47
47
|
|
48
|
-
response.body.
|
48
|
+
expect(response.body).to eq('User is authenticated')
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'should authenticate user' do
|
53
|
-
swap Devise::TokenAuthenticatable, :
|
53
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
54
54
|
post exhibit_user_path(user), Devise::TokenAuthenticatable.token_authentication_key => user.authentication_token, user: { some: "data" }
|
55
55
|
|
56
56
|
expect(warden).to be_authenticated(:user)
|
@@ -60,74 +60,139 @@ describe Devise::Strategies::TokenAuthenticatable do
|
|
60
60
|
|
61
61
|
context "when request is stateless" do
|
62
62
|
|
63
|
-
it 'should
|
64
|
-
swap Devise::TokenAuthenticatable, :
|
65
|
-
swap Devise, :
|
63
|
+
it 'should authenticate the user with use of authentication token' do
|
64
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
65
|
+
swap Devise, skip_session_storage: [:token_auth] do
|
66
66
|
sign_in_as_new_user_with_token
|
67
67
|
expect(warden).to be_authenticated(:user)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should redirect to the sign in page' do
|
73
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
74
|
+
swap Devise, skip_session_storage: [:token_auth] do
|
75
|
+
sign_in_as_new_user_with_token
|
76
|
+
|
77
|
+
# Try to access a resource that requires authentication
|
78
|
+
get users_path
|
79
|
+
expect(response).to redirect_to new_user_session_path
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should not store the session' do
|
85
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
86
|
+
swap Devise, skip_session_storage: [:token_auth] do
|
87
|
+
sign_in_as_new_user_with_token
|
68
88
|
|
69
89
|
# Try to access a resource that requires authentication
|
70
90
|
get users_path
|
71
|
-
response.should redirect_to(new_user_session_path)
|
72
91
|
expect(warden).to_not be_authenticated(:user)
|
73
92
|
end
|
74
93
|
end
|
75
94
|
end
|
95
|
+
|
76
96
|
end
|
77
97
|
|
78
98
|
context "when request is stateless and timeoutable" do
|
79
99
|
|
80
|
-
|
81
|
-
swap Devise::TokenAuthenticatable, :token_authentication_key => :secret_token do
|
82
|
-
swap Devise, :skip_session_storage => [:token_auth], timeout_in: (0.1).second do
|
83
|
-
user = sign_in_as_new_user_with_token
|
84
|
-
expect(warden).to be_authenticated(:user)
|
100
|
+
context "on sign in" do
|
85
101
|
|
86
|
-
|
87
|
-
|
102
|
+
it 'should authenticate the user' do
|
103
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
104
|
+
swap Devise, skip_session_storage: [:token_auth], timeout_in: (0.1).second do
|
105
|
+
sign_in_as_new_user_with_token
|
106
|
+
expect(warden).to be_authenticated(:user)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
88
110
|
|
89
|
-
|
90
|
-
expect(warden).to be_authenticated(:user)
|
111
|
+
end
|
91
112
|
|
92
|
-
|
113
|
+
context "on delayed access" do
|
114
|
+
|
115
|
+
it 'should authenticate the user' do
|
116
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
117
|
+
swap Devise, skip_session_storage: [:token_auth], timeout_in: (0.1).second do
|
118
|
+
user = sign_in_as_new_user_with_token
|
119
|
+
|
120
|
+
# Expiring does not work because we are setting the session value when accessing the resource
|
121
|
+
Timecop.travel(Time.now + (0.3).second)
|
122
|
+
|
123
|
+
sign_in_as_new_user_with_token(user: user)
|
124
|
+
expect(warden).to be_authenticated(:user)
|
125
|
+
|
126
|
+
Timecop.return
|
127
|
+
end
|
93
128
|
end
|
94
129
|
end
|
130
|
+
|
95
131
|
end
|
132
|
+
|
96
133
|
end
|
97
134
|
|
98
135
|
context "when expire_auth_token_on_timeout is set to true, timeoutable is enabled and we have a timed out session" do
|
99
136
|
|
100
|
-
|
101
|
-
swap Devise::TokenAuthenticatable, :token_authentication_key => :secret_token do
|
102
|
-
swap Devise, expire_auth_token_on_timeout: true, timeout_in: (-1).minute do
|
103
|
-
user = sign_in_as_new_user_with_token
|
104
|
-
expect(warden).to be_authenticated(:user)
|
105
|
-
token = user.authentication_token
|
137
|
+
context "on sign in" do
|
106
138
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
139
|
+
it 'should authenticate the user' do
|
140
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
141
|
+
swap Devise, expire_auth_token_on_timeout: true, timeout_in: (-1).minute do
|
142
|
+
sign_in_as_new_user_with_token
|
143
|
+
expect(warden).to be_authenticated(:user)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
context "on re-sign in" do
|
151
|
+
|
152
|
+
it 'should not authenticate the user' do
|
153
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
154
|
+
swap Devise, expire_auth_token_on_timeout: true, timeout_in: (-1).minute do
|
155
|
+
user = sign_in_as_new_user_with_token
|
156
|
+
token = user.authentication_token
|
157
|
+
|
158
|
+
sign_in_as_new_user_with_token(user: user)
|
159
|
+
expect(warden).to_not be_authenticated(:user)
|
160
|
+
end
|
111
161
|
end
|
112
162
|
end
|
163
|
+
|
164
|
+
it 'should reset the authentication token' do
|
165
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
166
|
+
swap Devise, expire_auth_token_on_timeout: true, timeout_in: (-1).minute do
|
167
|
+
user = sign_in_as_new_user_with_token
|
168
|
+
token = user.authentication_token
|
169
|
+
|
170
|
+
sign_in_as_new_user_with_token(user: user)
|
171
|
+
user.reload
|
172
|
+
expect(token).to_not eq(user.authentication_token)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
113
177
|
end
|
178
|
+
|
114
179
|
end
|
115
180
|
|
116
181
|
context "when not configured" do
|
117
182
|
|
118
183
|
it "should redirect to sign in page" do
|
119
|
-
swap Devise::TokenAuthenticatable, :
|
120
|
-
swap Devise, :
|
184
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
185
|
+
swap Devise, params_authenticatable: [:database] do
|
121
186
|
sign_in_as_new_user_with_token
|
122
187
|
|
123
|
-
response.
|
188
|
+
expect(response).to redirect_to new_user_session_path
|
124
189
|
end
|
125
190
|
end
|
126
191
|
end
|
127
192
|
|
128
193
|
it "should not authenticate user" do
|
129
|
-
swap Devise::TokenAuthenticatable, :
|
130
|
-
swap Devise, :
|
194
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
195
|
+
swap Devise, params_authenticatable: [:database] do
|
131
196
|
sign_in_as_new_user_with_token
|
132
197
|
|
133
198
|
expect(warden).to_not be_authenticated(:user)
|
@@ -140,17 +205,17 @@ describe Devise::Strategies::TokenAuthenticatable do
|
|
140
205
|
context "through http" do
|
141
206
|
|
142
207
|
it "should be a success" do
|
143
|
-
swap Devise::TokenAuthenticatable, :
|
208
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
144
209
|
swap Devise, http_authenticatable: true do
|
145
210
|
sign_in_as_new_user_with_token(http_auth: true)
|
146
211
|
|
147
|
-
response.
|
212
|
+
expect(response).to be_success
|
148
213
|
end
|
149
214
|
end
|
150
215
|
end
|
151
216
|
|
152
217
|
it "should authenticate user" do
|
153
|
-
swap Devise::TokenAuthenticatable, :
|
218
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
154
219
|
swap Devise, http_authenticatable: true do
|
155
220
|
sign_in_as_new_user_with_token(http_auth: true)
|
156
221
|
|
@@ -162,18 +227,18 @@ describe Devise::Strategies::TokenAuthenticatable do
|
|
162
227
|
context "when not configured" do
|
163
228
|
|
164
229
|
it "should be an unauthorized" do
|
165
|
-
swap Devise::TokenAuthenticatable, :
|
166
|
-
swap Devise, :
|
230
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
231
|
+
swap Devise, http_authenticatable: [:database] do
|
167
232
|
sign_in_as_new_user_with_token(http_auth: true)
|
168
233
|
|
169
|
-
response.status.
|
234
|
+
expect(response.status).to eq(401)
|
170
235
|
end
|
171
236
|
end
|
172
237
|
end
|
173
238
|
|
174
239
|
it "should not authenticate user" do
|
175
|
-
swap Devise::TokenAuthenticatable, :
|
176
|
-
swap Devise, :
|
240
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
241
|
+
swap Devise, http_authenticatable: [:database] do
|
177
242
|
sign_in_as_new_user_with_token(http_auth: true)
|
178
243
|
|
179
244
|
expect(warden).to_not be_authenticated(:user)
|
@@ -186,21 +251,30 @@ describe Devise::Strategies::TokenAuthenticatable do
|
|
186
251
|
context "through http header" do
|
187
252
|
|
188
253
|
it "should redirect to root path" do
|
189
|
-
swap Devise::TokenAuthenticatable, :
|
254
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
190
255
|
swap Devise, http_authenticatable: true do
|
191
256
|
sign_in_as_new_user_with_token(token_auth: true)
|
192
257
|
|
193
|
-
response.
|
258
|
+
expect(response).to be_success
|
194
259
|
end
|
195
260
|
end
|
196
261
|
end
|
197
262
|
|
198
|
-
it "should
|
199
|
-
swap Devise::TokenAuthenticatable, :
|
263
|
+
it "should not set any token options for Devise" do
|
264
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
200
265
|
swap Devise, http_authenticatable: true do
|
201
266
|
sign_in_as_new_user_with_token(token_auth: true)
|
202
267
|
|
203
268
|
expect(request.env['devise.token_options']).to eq({})
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
it "should authenticate user" do
|
274
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
275
|
+
swap Devise, http_authenticatable: true do
|
276
|
+
sign_in_as_new_user_with_token(token_auth: true)
|
277
|
+
|
204
278
|
expect(warden).to be_authenticated(:user)
|
205
279
|
end
|
206
280
|
end
|
@@ -210,18 +284,18 @@ describe Devise::Strategies::TokenAuthenticatable do
|
|
210
284
|
let(:signature) { "**TESTSIGNATURE**" }
|
211
285
|
|
212
286
|
it "should redirect to root path" do
|
213
|
-
swap Devise::TokenAuthenticatable, :
|
214
|
-
swap Devise, :
|
287
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
288
|
+
swap Devise, http_authenticatable: [:token_options] do
|
215
289
|
sign_in_as_new_user_with_token(token_auth: true, token_options: { signature: signature, nonce: 'def' })
|
216
290
|
|
217
|
-
response.
|
291
|
+
expect(response).to be_success
|
218
292
|
end
|
219
293
|
end
|
220
294
|
end
|
221
295
|
|
222
296
|
it "should set the signature option" do
|
223
|
-
swap Devise::TokenAuthenticatable, :
|
224
|
-
swap Devise, :
|
297
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
298
|
+
swap Devise, http_authenticatable: [:token_options] do
|
225
299
|
sign_in_as_new_user_with_token(token_auth: true, token_options: { signature: signature, nonce: 'def' })
|
226
300
|
|
227
301
|
expect(request.env['devise.token_options'][:signature]).to eq(signature)
|
@@ -230,8 +304,8 @@ describe Devise::Strategies::TokenAuthenticatable do
|
|
230
304
|
end
|
231
305
|
|
232
306
|
it "should set the nonce option" do
|
233
|
-
swap Devise::TokenAuthenticatable, :
|
234
|
-
swap Devise, :
|
307
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
308
|
+
swap Devise, http_authenticatable: [:token_options] do
|
235
309
|
sign_in_as_new_user_with_token(token_auth: true, token_options: { signature: signature, nonce: 'def' })
|
236
310
|
|
237
311
|
expect(request.env['devise.token_options'][:nonce]).to eq('def')
|
@@ -240,8 +314,8 @@ describe Devise::Strategies::TokenAuthenticatable do
|
|
240
314
|
end
|
241
315
|
|
242
316
|
it "should authenticate user" do
|
243
|
-
swap Devise::TokenAuthenticatable, :
|
244
|
-
swap Devise, :
|
317
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
318
|
+
swap Devise, http_authenticatable: [:token_options] do
|
245
319
|
sign_in_as_new_user_with_token(token_auth: true, token_options: { signature: signature, nonce: 'def' })
|
246
320
|
|
247
321
|
expect(warden).to be_authenticated(:user)
|
@@ -253,17 +327,17 @@ describe Devise::Strategies::TokenAuthenticatable do
|
|
253
327
|
context "with denied token authorization" do
|
254
328
|
|
255
329
|
it "should be an unauthorized" do
|
256
|
-
swap Devise::TokenAuthenticatable, :
|
330
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
257
331
|
swap Devise, http_authenticatable: false do
|
258
332
|
sign_in_as_new_user_with_token(token_auth: true)
|
259
333
|
|
260
|
-
response.status.
|
334
|
+
expect(response.status).to eq(401)
|
261
335
|
end
|
262
336
|
end
|
263
337
|
end
|
264
338
|
|
265
339
|
it "should not authenticate user" do
|
266
|
-
swap Devise::TokenAuthenticatable, :
|
340
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
267
341
|
swap Devise, http_authenticatable: false do
|
268
342
|
sign_in_as_new_user_with_token(token_auth: true)
|
269
343
|
|
@@ -271,42 +345,40 @@ describe Devise::Strategies::TokenAuthenticatable do
|
|
271
345
|
end
|
272
346
|
end
|
273
347
|
end
|
348
|
+
|
274
349
|
end
|
350
|
+
|
275
351
|
end
|
276
352
|
end
|
277
353
|
|
278
354
|
context "with improper authentication token key" do
|
279
355
|
|
280
356
|
it "should redirect to the sign in page" do
|
281
|
-
swap Devise::TokenAuthenticatable, :
|
282
|
-
sign_in_as_new_user_with_token(:
|
357
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :donald_duck_token do
|
358
|
+
sign_in_as_new_user_with_token(auth_token_key: :secret_token)
|
283
359
|
|
284
|
-
response.
|
360
|
+
expect(response).to redirect_to new_user_session_path
|
285
361
|
end
|
286
362
|
end
|
287
363
|
|
288
364
|
it "should not authenticate user" do
|
289
|
-
swap Devise::TokenAuthenticatable, :
|
290
|
-
sign_in_as_new_user_with_token(:
|
365
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :donald_duck_token do
|
366
|
+
sign_in_as_new_user_with_token(auth_token_key: :secret_token)
|
291
367
|
|
292
368
|
expect(warden).to_not be_authenticated(:user)
|
293
369
|
end
|
294
370
|
end
|
295
371
|
|
296
372
|
it "should not be subject to injection" do
|
297
|
-
swap Devise::TokenAuthenticatable, :
|
373
|
+
swap Devise::TokenAuthenticatable, token_authentication_key: :secret_token do
|
298
374
|
user1 = create(:user, :with_authentication_token)
|
299
|
-
|
300
|
-
# Clean up user cache
|
301
|
-
@user = nil
|
302
|
-
|
303
375
|
user2 = create(:user, :with_authentication_token)
|
304
376
|
|
305
|
-
expect(user1).to_not eq(user2)
|
306
377
|
get users_path(Devise::TokenAuthenticatable.token_authentication_key.to_s + '[$ne]' => user1.authentication_token)
|
307
378
|
expect(warden).to_not be_authenticated(:user)
|
308
379
|
end
|
309
380
|
end
|
381
|
+
|
310
382
|
end
|
311
383
|
|
312
384
|
context "with improper authentication token value" do
|
@@ -316,7 +388,7 @@ describe Devise::Strategies::TokenAuthenticatable do
|
|
316
388
|
before { sign_in_as_new_user_with_token(auth_token: '*** INVALID TOKEN ***') }
|
317
389
|
|
318
390
|
it "should redirect to the sign in page" do
|
319
|
-
response.
|
391
|
+
expect(response).to redirect_to new_user_session_path
|
320
392
|
end
|
321
393
|
|
322
394
|
it "should not authenticate user" do
|
@@ -329,7 +401,7 @@ describe Devise::Strategies::TokenAuthenticatable do
|
|
329
401
|
before { sign_in_as_new_user_with_token(token_auth: true, auth_token: '*** INVALID TOKEN ***') }
|
330
402
|
|
331
403
|
it "should be an unauthorized" do
|
332
|
-
response.status.
|
404
|
+
expect(response.status).to eq(401)
|
333
405
|
end
|
334
406
|
|
335
407
|
it "does not authenticate with improper authentication token value in header" do
|
data/spec/spec_helper.rb
CHANGED
@@ -9,7 +9,7 @@ require 'timecop'
|
|
9
9
|
require 'pry'
|
10
10
|
|
11
11
|
# Required spec helper files
|
12
|
-
require 'support/rails_app'
|
12
|
+
require 'support/rails_app/config/environment'
|
13
13
|
require 'support/helpers'
|
14
14
|
require 'support/integration'
|
15
15
|
require 'support/session_helper'
|
@@ -18,10 +18,12 @@ require 'support/session_helper'
|
|
18
18
|
# as it sets the right application root path
|
19
19
|
require 'factory_girl_rails'
|
20
20
|
|
21
|
+
# Do not show migration output
|
22
|
+
ActiveRecord::Migration.verbose = false
|
23
|
+
|
21
24
|
# RSpec configuration
|
22
25
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
23
26
|
RSpec.configure do |config|
|
24
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
25
27
|
config.use_transactional_fixtures = true
|
26
28
|
config.run_all_when_everything_filtered = true
|
27
29
|
|
@@ -35,6 +37,8 @@ RSpec.configure do |config|
|
|
35
37
|
|
36
38
|
config.include FactoryGirl::Syntax::Methods
|
37
39
|
|
40
|
+
config.infer_spec_type_from_file_location!
|
41
|
+
|
38
42
|
config.before(:suite) do
|
39
43
|
# Do initial migration
|
40
44
|
ActiveRecord::Migrator.migrate(File.expand_path("support/rails_app/db/migrate/", File.dirname(__FILE__)))
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
class ApplicationController < ActionController::Base
|
5
5
|
protect_from_forgery
|
6
|
-
before_filter :current_user,
|
7
|
-
before_filter :authenticate_user!,
|
6
|
+
before_filter :current_user, unless: :devise_controller?
|
7
|
+
before_filter :authenticate_user!, if: :devise_controller?
|
8
8
|
respond_to *Mime::SET.map(&:to_sym)
|
9
9
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
class UsersController < ApplicationController
|
2
|
-
prepend_before_filter :current_user,
|
3
|
-
before_filter
|
2
|
+
prepend_before_filter :current_user, only: :exhibit
|
3
|
+
before_filter :authenticate_user!, except: [:accept, :exhibit]
|
4
|
+
|
4
5
|
respond_to :html, :xml
|
5
6
|
|
6
7
|
def index
|
@@ -13,7 +14,7 @@ class UsersController < ApplicationController
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def update_form
|
16
|
-
render :
|
17
|
+
render text: 'Update'
|
17
18
|
end
|
18
19
|
|
19
20
|
def accept
|
@@ -21,11 +22,11 @@ class UsersController < ApplicationController
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def exhibit
|
24
|
-
render :
|
25
|
+
render text: current_user ? "User is authenticated" : "User is not authenticated"
|
25
26
|
end
|
26
27
|
|
27
28
|
def expire
|
28
29
|
user_session['last_request_at'] = 31.minutes.ago.utc
|
29
|
-
render :
|
30
|
+
render text: 'User will be expired on next request'
|
30
31
|
end
|
31
32
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class Users::Mailer < Devise::Mailer
|
2
|
-
default :
|
2
|
+
default from: 'custom@example.com'
|
3
3
|
end
|
4
4
|
|
5
5
|
class Users::ReplyToMailer < Devise::Mailer
|
6
|
-
default :
|
7
|
-
default :
|
6
|
+
default from: 'custom@example.com'
|
7
|
+
default reply_to: 'custom_reply_to@example.com'
|
8
8
|
end
|
9
9
|
|
10
10
|
class Users::FromProcMailer < Devise::Mailer
|
11
|
-
default :
|
11
|
+
default from: proc { 'custom@example.com' }
|
12
12
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class Admin < ActiveRecord::Base
|
2
2
|
devise :database_authenticatable, :registerable,
|
3
3
|
:timeoutable, :recoverable, :lockable, :confirmable,
|
4
|
-
:
|
5
|
-
:
|
4
|
+
unlock_strategy: :time, lock_strategy: :none,
|
5
|
+
allow_unconfirmed_access_for: 2.weeks, reconfirmable: true
|
6
6
|
|
7
|
-
validates_length_of :reset_password_token,
|
8
|
-
validates_uniqueness_of :email,
|
7
|
+
validates_length_of :reset_password_token, minimum: 3, allow_blank: true
|
8
|
+
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
|
9
9
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
module Devise
|
4
|
+
module TokenAuthenticatable
|
5
|
+
class RailsApp < Rails::Application
|
6
|
+
config.active_support.deprecation = :log
|
7
|
+
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
|
8
|
+
config.action_mailer.delivery_method = :test
|
9
|
+
config.i18n.enforce_available_locales = false
|
10
|
+
config.eager_load = false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,4 +1,7 @@
|
|
1
1
|
config = Rails.application.config
|
2
2
|
|
3
|
-
|
4
|
-
config.
|
3
|
+
if Rails.version.start_with? '4'
|
4
|
+
config.secret_key_base = 'd588e99efff13a86461fd6ab82327823ad2f8feb5dc217ce652cdd9f0dfc5eb4b5a62a92d24d2574d7d51dfb1ea8dd453ea54e00cf672159a13104a135422a10'
|
5
|
+
else
|
6
|
+
config.secret_token = 'ea942c41850d502f2c8283e26bdc57829f471bb18224ddff0a192c4f32cdf6cb5aa0d82b3a7a7adbeb640c4b06f3aa1cd5f098162d8240f669b39d6b49680571'
|
7
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Devise::TokenAuthenticatable::RailsApp.config.session_store :cookie_store, key: '_my_app'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
# Resources for testing
|
3
|
-
resources :users, :
|
3
|
+
resources :users, only: [:index] do
|
4
4
|
member do
|
5
5
|
get :expire
|
6
6
|
get :accept
|
@@ -9,96 +9,110 @@ Rails.application.routes.draw do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
authenticate do
|
12
|
-
post :exhibit, :
|
12
|
+
post :exhibit, on: :member
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
resources :admins, :
|
17
|
-
get :expire, :
|
16
|
+
resources :admins, only: [:index] do
|
17
|
+
get :expire, on: :member
|
18
18
|
end
|
19
19
|
|
20
20
|
# Users scope
|
21
|
-
devise_for :users
|
21
|
+
devise_for :users
|
22
22
|
|
23
23
|
as :user do
|
24
|
-
get "/as/sign_in", :
|
24
|
+
get "/as/sign_in", to: "devise/sessions#new"
|
25
25
|
end
|
26
26
|
|
27
|
-
get "/sign_in", :
|
27
|
+
get "/sign_in", to: "devise/sessions#new"
|
28
28
|
|
29
29
|
# Admin scope
|
30
|
-
devise_for :admin, :
|
30
|
+
devise_for :admin, path: "admin_area", controllers: { sessions: "admins/sessions" }, skip: :passwords
|
31
31
|
|
32
|
-
get "/admin_area/home", :
|
33
|
-
get "/anywhere",
|
32
|
+
get "/admin_area/home", to: "admins#index", as: :admin_root
|
33
|
+
get "/anywhere", to: "foo#bar", as: :new_admin_password
|
34
34
|
|
35
35
|
authenticate(:admin) do
|
36
|
-
get "/private", :
|
36
|
+
get "/private", to: "home#private", as: :private
|
37
37
|
end
|
38
38
|
|
39
39
|
authenticate(:admin, lambda { |admin| admin.active? }) do
|
40
|
-
get "/private/active", :
|
40
|
+
get "/private/active", to: "home#private", as: :private_active
|
41
41
|
end
|
42
42
|
|
43
43
|
authenticated :admin do
|
44
|
-
get "/dashboard", :
|
44
|
+
get "/dashboard", to: "home#admin_dashboard"
|
45
45
|
end
|
46
46
|
|
47
47
|
authenticated :admin, lambda { |admin| admin.active? } do
|
48
|
-
get "/dashboard/active", :
|
48
|
+
get "/dashboard/active", to: "home#admin_dashboard"
|
49
49
|
end
|
50
50
|
|
51
51
|
authenticated do
|
52
|
-
get "/dashboard", :
|
52
|
+
get "/dashboard", to: "home#user_dashboard"
|
53
53
|
end
|
54
54
|
|
55
55
|
unauthenticated do
|
56
|
-
get "/join", :
|
56
|
+
get "/join", to: "home#join"
|
57
57
|
end
|
58
58
|
|
59
59
|
# Routes for constraints testing
|
60
|
-
devise_for :headquarters_admin, :
|
60
|
+
devise_for :headquarters_admin, class_name: "Admin", path: "headquarters", constraints: { host: /192\.168\.1\.\d\d\d/ }
|
61
61
|
|
62
|
-
constraints(:
|
63
|
-
devise_for :homebase_admin, :
|
62
|
+
constraints(host: /192\.168\.1\.\d\d\d/) do
|
63
|
+
devise_for :homebase_admin, class_name: "Admin", path: "homebase"
|
64
64
|
end
|
65
65
|
|
66
|
-
devise_for :skip_admin, :
|
66
|
+
devise_for :skip_admin, class_name: "Admin", skip: :all
|
67
67
|
|
68
68
|
# Routes for format=false testing
|
69
|
-
devise_for :htmlonly_admin, :
|
70
|
-
|
69
|
+
devise_for :htmlonly_admin, class_name: "Admin",
|
70
|
+
skip: [:confirmations, :unlocks],
|
71
|
+
path: "htmlonly_admin",
|
72
|
+
format: false,
|
73
|
+
skip_helpers: [:confirmations, :unlocks]
|
74
|
+
|
75
|
+
devise_for :htmlonly_users, class_name: "User",
|
76
|
+
only: [:confirmations, :unlocks],
|
77
|
+
path: "htmlonly_users",
|
78
|
+
format: false,
|
79
|
+
skip_helpers: true
|
71
80
|
|
72
81
|
# Other routes for routing_test.rb
|
73
|
-
devise_for :reader, :
|
82
|
+
devise_for :reader, class_name: "User", only: :passwords
|
74
83
|
|
75
|
-
scope :
|
76
|
-
devise_for :sub_admin, :
|
84
|
+
scope host: "sub.example.com" do
|
85
|
+
devise_for :sub_admin, class_name: "Admin"
|
77
86
|
end
|
78
87
|
|
79
|
-
namespace :publisher, :
|
80
|
-
devise_for :accounts, :
|
88
|
+
namespace :publisher, path_names: { sign_in: "i_dont_care", sign_out: "get_out" } do
|
89
|
+
devise_for :accounts, class_name: "Admin", path_names: { sign_in: "get_in" }
|
81
90
|
end
|
82
91
|
|
83
|
-
scope ":locale", :
|
84
|
-
devise_for :accounts, :
|
85
|
-
:
|
86
|
-
:
|
87
|
-
:
|
88
|
-
:
|
89
|
-
:
|
90
|
-
|
92
|
+
scope ":locale", module: :invalid do
|
93
|
+
devise_for :accounts, singular: "manager", class_name: "Admin",
|
94
|
+
path_names: {
|
95
|
+
sign_in: "login",
|
96
|
+
sign_out: "logout",
|
97
|
+
password: "secret",
|
98
|
+
confirmation: "verification",
|
99
|
+
unlock: "unblock",
|
100
|
+
sign_up: "register",
|
101
|
+
registration: "management",
|
102
|
+
cancel: "giveup"
|
103
|
+
}, failure_app: lambda { |env| [404, { "Content-Type" => "text/plain" }, ["Oops, not found"]] },
|
104
|
+
module: :devise
|
91
105
|
end
|
92
106
|
|
93
|
-
namespace :sign_out_via, :
|
94
|
-
devise_for :deletes,
|
95
|
-
devise_for :posts,
|
96
|
-
devise_for :delete_or_posts,
|
107
|
+
namespace :sign_out_via, module: "devise" do
|
108
|
+
devise_for :deletes, sign_out_via: :delete, class_name: "Admin"
|
109
|
+
devise_for :posts, sign_out_via: :post, class_name: "Admin"
|
110
|
+
devise_for :delete_or_posts, sign_out_via: [:delete, :post], class_name: "Admin"
|
97
111
|
end
|
98
112
|
|
99
|
-
get "/set",
|
100
|
-
get "/unauthenticated", :
|
113
|
+
get "/set", to: "home#set"
|
114
|
+
get "/unauthenticated", to: "home#unauthenticated"
|
101
115
|
get "/custom_strategy/new"
|
102
116
|
|
103
|
-
root :
|
117
|
+
root to: "home#index", via: [:get, :post]
|
104
118
|
end
|
metadata
CHANGED
@@ -1,188 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise-token_authenticatable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0.beta1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sebastian Oelke
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-08-21 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: devise
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 3.
|
19
|
+
version: 3.3.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 3.
|
26
|
+
version: 3.3.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
28
|
+
name: rails
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
33
|
+
version: 4.1.0
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: actionmailer
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '3.2'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3.2'
|
40
|
+
version: 4.1.0
|
62
41
|
- !ruby/object:Gem::Dependency
|
63
42
|
name: rspec-rails
|
64
43
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
44
|
requirements:
|
67
|
-
- -
|
45
|
+
- - "~>"
|
68
46
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
47
|
+
version: 3.0.2
|
70
48
|
type: :development
|
71
49
|
prerelease: false
|
72
50
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
51
|
requirements:
|
75
|
-
- -
|
52
|
+
- - "~>"
|
76
53
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
54
|
+
version: 3.0.2
|
78
55
|
- !ruby/object:Gem::Dependency
|
79
56
|
name: pry
|
80
57
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
58
|
requirements:
|
83
|
-
- -
|
59
|
+
- - "~>"
|
84
60
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
61
|
+
version: 0.10.0
|
86
62
|
type: :development
|
87
63
|
prerelease: false
|
88
64
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
65
|
requirements:
|
91
|
-
- -
|
66
|
+
- - "~>"
|
92
67
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
68
|
+
version: 0.10.0
|
94
69
|
- !ruby/object:Gem::Dependency
|
95
70
|
name: factory_girl_rails
|
96
71
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
72
|
requirements:
|
99
|
-
- -
|
73
|
+
- - "~>"
|
100
74
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
75
|
+
version: 4.4.0
|
102
76
|
type: :development
|
103
77
|
prerelease: false
|
104
78
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
79
|
requirements:
|
107
|
-
- -
|
80
|
+
- - "~>"
|
108
81
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
82
|
+
version: 4.4.0
|
110
83
|
- !ruby/object:Gem::Dependency
|
111
84
|
name: timecop
|
112
85
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
86
|
requirements:
|
115
|
-
- -
|
87
|
+
- - "~>"
|
116
88
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
89
|
+
version: 0.7.0
|
118
90
|
type: :development
|
119
91
|
prerelease: false
|
120
92
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
93
|
requirements:
|
123
|
-
- -
|
94
|
+
- - "~>"
|
124
95
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
96
|
+
version: 0.7.0
|
126
97
|
- !ruby/object:Gem::Dependency
|
127
98
|
name: bundler
|
128
99
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
100
|
requirements:
|
131
|
-
- - ~>
|
101
|
+
- - "~>"
|
132
102
|
- !ruby/object:Gem::Version
|
133
|
-
version: '1.
|
103
|
+
version: '1.6'
|
134
104
|
type: :development
|
135
105
|
prerelease: false
|
136
106
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
107
|
requirements:
|
139
|
-
- - ~>
|
108
|
+
- - "~>"
|
140
109
|
- !ruby/object:Gem::Version
|
141
|
-
version: '1.
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: rake
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '0'
|
150
|
-
type: :development
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ! '>='
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0'
|
110
|
+
version: '1.6'
|
158
111
|
- !ruby/object:Gem::Dependency
|
159
112
|
name: sqlite3
|
160
113
|
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
114
|
requirements:
|
163
|
-
- - ~>
|
115
|
+
- - "~>"
|
164
116
|
- !ruby/object:Gem::Version
|
165
117
|
version: '1.3'
|
166
118
|
type: :development
|
167
119
|
prerelease: false
|
168
120
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
121
|
requirements:
|
171
|
-
- - ~>
|
122
|
+
- - "~>"
|
172
123
|
- !ruby/object:Gem::Version
|
173
124
|
version: '1.3'
|
174
|
-
description:
|
175
|
-
|
176
|
-
|
177
|
-
|
125
|
+
description: |-
|
126
|
+
This gem provides the extracted Token Authenticatable module of devise.
|
127
|
+
It enables the user to sign in via an authentication token. This token
|
128
|
+
can be given via a query string or HTTP Basic Authentication.
|
178
129
|
email:
|
179
130
|
- dev@sohleeatsworld.de
|
180
131
|
executables: []
|
181
132
|
extensions: []
|
182
133
|
extra_rdoc_files: []
|
183
134
|
files:
|
184
|
-
- .gitignore
|
185
|
-
- .travis.yml
|
135
|
+
- ".gitignore"
|
136
|
+
- ".travis.yml"
|
186
137
|
- Gemfile
|
187
138
|
- LICENSE
|
188
139
|
- README.md
|
@@ -200,7 +151,6 @@ files:
|
|
200
151
|
- spec/spec_helper.rb
|
201
152
|
- spec/support/helpers.rb
|
202
153
|
- spec/support/integration.rb
|
203
|
-
- spec/support/rails_app.rb
|
204
154
|
- spec/support/rails_app/Rakefile
|
205
155
|
- spec/support/rails_app/app/controllers/admins/sessions_controller.rb
|
206
156
|
- spec/support/rails_app/app/controllers/admins_controller.rb
|
@@ -214,11 +164,15 @@ files:
|
|
214
164
|
- spec/support/rails_app/app/models/user.rb
|
215
165
|
- spec/support/rails_app/app/views/users/index.html.erb
|
216
166
|
- spec/support/rails_app/config.ru
|
167
|
+
- spec/support/rails_app/config/application.rb
|
168
|
+
- spec/support/rails_app/config/boot.rb
|
217
169
|
- spec/support/rails_app/config/database.yml
|
170
|
+
- spec/support/rails_app/config/environment.rb
|
218
171
|
- spec/support/rails_app/config/initializers/backtrace_silencers.rb
|
219
172
|
- spec/support/rails_app/config/initializers/devise.rb
|
220
173
|
- spec/support/rails_app/config/initializers/inflections.rb
|
221
174
|
- spec/support/rails_app/config/initializers/secret_token.rb
|
175
|
+
- spec/support/rails_app/config/initializers/session_store.rb
|
222
176
|
- spec/support/rails_app/config/routes.rb
|
223
177
|
- spec/support/rails_app/db/migrate/20100401102949_create_tables.rb
|
224
178
|
- spec/support/rails_app/db/schema.rb
|
@@ -230,27 +184,26 @@ files:
|
|
230
184
|
homepage: https://github.com/baschtl/devise-token_authenticatable
|
231
185
|
licenses:
|
232
186
|
- MIT
|
187
|
+
metadata: {}
|
233
188
|
post_install_message:
|
234
189
|
rdoc_options: []
|
235
190
|
require_paths:
|
236
191
|
- lib
|
237
192
|
required_ruby_version: !ruby/object:Gem::Requirement
|
238
|
-
none: false
|
239
193
|
requirements:
|
240
|
-
- -
|
194
|
+
- - ">="
|
241
195
|
- !ruby/object:Gem::Version
|
242
196
|
version: '0'
|
243
197
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
244
|
-
none: false
|
245
198
|
requirements:
|
246
|
-
- -
|
199
|
+
- - ">"
|
247
200
|
- !ruby/object:Gem::Version
|
248
|
-
version:
|
201
|
+
version: 1.3.1
|
249
202
|
requirements: []
|
250
203
|
rubyforge_project:
|
251
|
-
rubygems_version:
|
204
|
+
rubygems_version: 2.2.2
|
252
205
|
signing_key:
|
253
|
-
specification_version:
|
206
|
+
specification_version: 4
|
254
207
|
summary: Provides authentication based on an authentication token for devise 3.2 and
|
255
208
|
up.
|
256
209
|
test_files:
|
@@ -261,7 +214,6 @@ test_files:
|
|
261
214
|
- spec/spec_helper.rb
|
262
215
|
- spec/support/helpers.rb
|
263
216
|
- spec/support/integration.rb
|
264
|
-
- spec/support/rails_app.rb
|
265
217
|
- spec/support/rails_app/Rakefile
|
266
218
|
- spec/support/rails_app/app/controllers/admins/sessions_controller.rb
|
267
219
|
- spec/support/rails_app/app/controllers/admins_controller.rb
|
@@ -275,11 +227,15 @@ test_files:
|
|
275
227
|
- spec/support/rails_app/app/models/user.rb
|
276
228
|
- spec/support/rails_app/app/views/users/index.html.erb
|
277
229
|
- spec/support/rails_app/config.ru
|
230
|
+
- spec/support/rails_app/config/application.rb
|
231
|
+
- spec/support/rails_app/config/boot.rb
|
278
232
|
- spec/support/rails_app/config/database.yml
|
233
|
+
- spec/support/rails_app/config/environment.rb
|
279
234
|
- spec/support/rails_app/config/initializers/backtrace_silencers.rb
|
280
235
|
- spec/support/rails_app/config/initializers/devise.rb
|
281
236
|
- spec/support/rails_app/config/initializers/inflections.rb
|
282
237
|
- spec/support/rails_app/config/initializers/secret_token.rb
|
238
|
+
- spec/support/rails_app/config/initializers/session_store.rb
|
283
239
|
- spec/support/rails_app/config/routes.rb
|
284
240
|
- spec/support/rails_app/db/migrate/20100401102949_create_tables.rb
|
285
241
|
- spec/support/rails_app/db/schema.rb
|
@@ -288,3 +244,4 @@ test_files:
|
|
288
244
|
- spec/support/rails_app/public/500.html
|
289
245
|
- spec/support/rails_app/public/favicon.ico
|
290
246
|
- spec/support/session_helper.rb
|
247
|
+
has_rdoc:
|
data/spec/support/rails_app.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# Initializes the rails application used for
|
2
|
-
# testing.
|
3
|
-
|
4
|
-
# Do not output schema loading
|
5
|
-
ActiveRecord::Migration.verbose = false
|
6
|
-
|
7
|
-
module Devise
|
8
|
-
module TokenAuthenticatable
|
9
|
-
class RailsApp < Rails::Application
|
10
|
-
config.root = File.dirname(__FILE__) + "/rails_app"
|
11
|
-
config.active_support.deprecation = :log
|
12
|
-
config.action_mailer.default_url_options = { :host => "localhost:3000" }
|
13
|
-
config.action_mailer.delivery_method = :test
|
14
|
-
config.eager_load = false
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
Devise::TokenAuthenticatable::RailsApp.initialize!
|