doorkeeper 5.0.0.rc1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +16 -0
- data/NEWS.md +36 -2
- data/README.md +9 -8
- data/UPGRADE.md +2 -0
- data/app/controllers/doorkeeper/authorizations_controller.rb +1 -1
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +4 -1
- data/app/controllers/doorkeeper/tokens_controller.rb +9 -10
- data/app/views/doorkeeper/applications/index.html.erb +1 -1
- data/config/locales/en.yml +1 -0
- data/doorkeeper.gemspec +18 -18
- data/gemfiles/rails_master.gemfile +4 -1
- data/lib/doorkeeper/config.rb +18 -5
- data/lib/doorkeeper/models/access_grant_mixin.rb +15 -0
- data/lib/doorkeeper/models/access_token_mixin.rb +3 -3
- data/lib/doorkeeper/oauth/authorization/token.rb +24 -19
- data/lib/doorkeeper/oauth/base_request.rb +3 -2
- data/lib/doorkeeper/oauth/client.rb +0 -2
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +2 -1
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +2 -4
- data/lib/doorkeeper/oauth/client_credentials/validation.rb +0 -4
- data/lib/doorkeeper/oauth/client_credentials_request.rb +0 -4
- data/lib/doorkeeper/oauth/refresh_token_request.rb +2 -2
- data/lib/doorkeeper/orm/active_record/application.rb +11 -0
- data/lib/doorkeeper/rails/routes.rb +4 -4
- data/lib/doorkeeper/request/authorization_code.rb +0 -2
- data/lib/doorkeeper/request/client_credentials.rb +0 -2
- data/lib/doorkeeper/request/code.rb +0 -2
- data/lib/doorkeeper/request/password.rb +0 -2
- data/lib/doorkeeper/request/refresh_token.rb +0 -2
- data/lib/doorkeeper/request/token.rb +0 -2
- data/lib/doorkeeper/request.rb +0 -7
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/doorkeeper.rb +15 -0
- data/lib/generators/doorkeeper/templates/initializer.rb +18 -4
- data/spec/controllers/authorizations_controller_spec.rb +31 -4
- data/spec/controllers/tokens_controller_spec.rb +60 -8
- data/spec/dummy/config/initializers/doorkeeper.rb +5 -1
- data/spec/lib/config_spec.rb +29 -0
- data/spec/lib/oauth/base_request_spec.rb +24 -0
- data/spec/models/doorkeeper/access_grant_spec.rb +43 -0
- data/spec/models/doorkeeper/access_token_spec.rb +16 -6
- data/spec/models/doorkeeper/application_spec.rb +13 -0
- data/spec/requests/applications/applications_request_spec.rb +45 -0
- data/spec/requests/flows/authorization_code_spec.rb +4 -4
- data/spec/support/helpers/request_spec_helper.rb +8 -0
- metadata +10 -8
|
@@ -10,13 +10,20 @@ Doorkeeper.configure do
|
|
|
10
10
|
# User.find_by_id(session[:user_id]) || redirect_to(new_user_session_url)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
# If you
|
|
14
|
-
# you need to declare
|
|
13
|
+
# If you didn't skip applications controller from Doorkeeper routes in your application routes.rb
|
|
14
|
+
# file then you need to declare this block in order to restrict access to the web interface for
|
|
15
|
+
# adding oauth authorized applications. In other case it will return 403 Forbidden response
|
|
16
|
+
# every time somebody will try to access the admin web interface.
|
|
15
17
|
#
|
|
16
18
|
# admin_authenticator do
|
|
17
19
|
# # Put your admin authentication logic here.
|
|
18
20
|
# # Example implementation:
|
|
19
|
-
#
|
|
21
|
+
#
|
|
22
|
+
# if current_user
|
|
23
|
+
# head :forbidden unless current_user.admin?
|
|
24
|
+
# else
|
|
25
|
+
# redirect_to sign_in_url
|
|
26
|
+
# end
|
|
20
27
|
# end
|
|
21
28
|
|
|
22
29
|
# If you are planning to use Doorkeeper in Rails 5 API-only application, then you might
|
|
@@ -66,7 +73,14 @@ Doorkeeper.configure do
|
|
|
66
73
|
#
|
|
67
74
|
# reuse_access_token
|
|
68
75
|
|
|
69
|
-
# Issue access tokens with refresh token (disabled by default)
|
|
76
|
+
# Issue access tokens with refresh token (disabled by default), you may also
|
|
77
|
+
# pass a block which accepts `context` to customize when to give a refresh
|
|
78
|
+
# token or not. Similar to `custom_access_token_expires_in`, `context` has
|
|
79
|
+
# the properties:
|
|
80
|
+
#
|
|
81
|
+
# `client` - the OAuth client application (see Doorkeeper::OAuth::Client)
|
|
82
|
+
# `grant_type` - the grant type of the request (see Doorkeeper::OAuth)
|
|
83
|
+
# `scopes` - the requested scopes (see Doorkeeper::OAuth::Scopes)
|
|
70
84
|
#
|
|
71
85
|
# use_refresh_token
|
|
72
86
|
|
|
@@ -57,7 +57,7 @@ describe Doorkeeper::AuthorizationsController, 'implicit grant flow' do
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
it 'includes token type in fragment' do
|
|
60
|
-
expect(response.query_params['token_type']).to eq('
|
|
60
|
+
expect(response.query_params['token_type']).to eq('Bearer')
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
it 'includes token expiration in fragment' do
|
|
@@ -95,7 +95,7 @@ describe Doorkeeper::AuthorizationsController, 'implicit grant flow' do
|
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
it "includes token type in fragment" do
|
|
98
|
-
expect(redirect_uri.match(/token_type=(\w+)&?/)[1]).to eq "
|
|
98
|
+
expect(redirect_uri.match(/token_type=(\w+)&?/)[1]).to eq "Bearer"
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
it "includes token expiration in fragment" do
|
|
@@ -293,7 +293,7 @@ describe Doorkeeper::AuthorizationsController, 'implicit grant flow' do
|
|
|
293
293
|
end
|
|
294
294
|
|
|
295
295
|
it 'includes token type in fragment' do
|
|
296
|
-
expect(response.query_params['token_type']).to eq('
|
|
296
|
+
expect(response.query_params['token_type']).to eq('Bearer')
|
|
297
297
|
end
|
|
298
298
|
|
|
299
299
|
it 'includes token expiration in fragment' do
|
|
@@ -355,7 +355,7 @@ describe Doorkeeper::AuthorizationsController, 'implicit grant flow' do
|
|
|
355
355
|
it "sets redirect_uri to correct value" do
|
|
356
356
|
redirect_uri = JSON.parse(response.body)["redirect_uri"]
|
|
357
357
|
expect(redirect_uri).to_not be_nil
|
|
358
|
-
expect(redirect_uri.match(/token_type=(\w+)&?/)[1]).to eq "
|
|
358
|
+
expect(redirect_uri.match(/token_type=(\w+)&?/)[1]).to eq "Bearer"
|
|
359
359
|
expect(redirect_uri.match(/expires_in=(\d+)&?/)[1].to_i).to eq 1234
|
|
360
360
|
expect(
|
|
361
361
|
redirect_uri.match(/access_token=([a-f0-9]+)&?/)[1]
|
|
@@ -387,6 +387,33 @@ describe Doorkeeper::AuthorizationsController, 'implicit grant flow' do
|
|
|
387
387
|
end
|
|
388
388
|
end
|
|
389
389
|
|
|
390
|
+
describe 'GET #new in API mode with errors' do
|
|
391
|
+
let(:response_json_body) { JSON.parse(response.body) }
|
|
392
|
+
|
|
393
|
+
before do
|
|
394
|
+
default_scopes_exist :public
|
|
395
|
+
allow(Doorkeeper.configuration).to receive(:api_only).and_return(true)
|
|
396
|
+
get :new, params: { an_invalid: 'request' }
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
it 'should render bad request' do
|
|
400
|
+
expect(response).to have_http_status(:bad_request)
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
it 'includes error in body' do
|
|
404
|
+
expect(response_json_body['error']).to eq('unsupported_response_type')
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
it 'includes error description in body' do
|
|
408
|
+
expect(response_json_body['error_description']).to eq(translated_error_message(:unsupported_response_type))
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
it 'does not issue any token' do
|
|
412
|
+
expect(Doorkeeper::AccessGrant.count).to eq 0
|
|
413
|
+
expect(Doorkeeper::AccessToken.count).to eq 0
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
|
|
390
417
|
describe 'GET #new with callbacks' do
|
|
391
418
|
after do
|
|
392
419
|
client.update_attribute :redirect_uri, 'urn:ietf:wg:oauth:2.0:oob'
|
|
@@ -33,7 +33,7 @@ describe Doorkeeper::TokensController do
|
|
|
33
33
|
allow(I18n).to receive(:translate).
|
|
34
34
|
with(
|
|
35
35
|
custom_message,
|
|
36
|
-
hash_including(scope: %i[doorkeeper errors messages])
|
|
36
|
+
hash_including(scope: %i[doorkeeper errors messages])
|
|
37
37
|
).
|
|
38
38
|
and_return('Authorization custom message')
|
|
39
39
|
|
|
@@ -56,15 +56,67 @@ describe Doorkeeper::TokensController do
|
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
# http://tools.ietf.org/html/rfc7009#section-2.2
|
|
60
|
+
describe 'revoking tokens' do
|
|
61
|
+
let(:client) { FactoryBot.create(:application) }
|
|
62
|
+
let(:access_token) { FactoryBot.create(:access_token, application: client) }
|
|
63
|
+
|
|
64
|
+
before(:each) do
|
|
65
|
+
allow(controller).to receive(:token) { access_token }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context 'when associated app is public' do
|
|
69
|
+
let(:client) { FactoryBot.create(:application, confidential: false) }
|
|
70
|
+
|
|
71
|
+
it 'returns 200' do
|
|
72
|
+
post :revoke
|
|
73
|
+
|
|
74
|
+
expect(response.status).to eq 200
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'revokes the access token' do
|
|
78
|
+
post :revoke
|
|
79
|
+
|
|
80
|
+
expect(access_token.reload).to have_attributes(revoked?: true)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
context 'when associated app is confidential' do
|
|
85
|
+
let(:client) { FactoryBot.create(:application, confidential: true) }
|
|
86
|
+
let(:oauth_client) { Doorkeeper::OAuth::Client.new(client) }
|
|
64
87
|
|
|
65
|
-
|
|
88
|
+
before(:each) do
|
|
89
|
+
allow_any_instance_of(Doorkeeper::Server).to receive(:client) { oauth_client }
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'returns 200' do
|
|
93
|
+
post :revoke
|
|
94
|
+
|
|
95
|
+
expect(response.status).to eq 200
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'revokes the access token' do
|
|
99
|
+
post :revoke
|
|
100
|
+
|
|
101
|
+
expect(access_token.reload).to have_attributes(revoked?: true)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
context 'when authorization fails' do
|
|
105
|
+
let(:some_other_client) { FactoryBot.create(:application, confidential: true) }
|
|
106
|
+
let(:oauth_client) { Doorkeeper::OAuth::Client.new(some_other_client) }
|
|
107
|
+
|
|
108
|
+
it 'returns 200' do
|
|
109
|
+
post :revoke
|
|
66
110
|
|
|
67
|
-
|
|
111
|
+
expect(response.status).to eq 200
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it 'does not revoke the access token' do
|
|
115
|
+
post :revoke
|
|
116
|
+
|
|
117
|
+
expect(access_token.reload).to have_attributes(revoked?: false)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
68
120
|
end
|
|
69
121
|
end
|
|
70
122
|
|
|
@@ -8,7 +8,11 @@ Doorkeeper.configure do
|
|
|
8
8
|
User.where(id: session[:user_id]).first || redirect_to(root_url, alert: 'Needs sign in.')
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
# If you
|
|
11
|
+
# If you didn't skip applications controller from Doorkeeper routes in your application routes.rb
|
|
12
|
+
# file then you need to declare this block in order to restrict access to the web interface for
|
|
13
|
+
# adding oauth authorized applications. In other case it will return 403 Forbidden response
|
|
14
|
+
# every time somebody will try to access the admin web interface.
|
|
15
|
+
#
|
|
12
16
|
# admin_authenticator do
|
|
13
17
|
# # Put your admin authentication logic here.
|
|
14
18
|
# # Example implementation:
|
data/spec/lib/config_spec.rb
CHANGED
|
@@ -66,6 +66,17 @@ describe Doorkeeper, 'configuration' do
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
describe 'admin_authenticator' do
|
|
69
|
+
it 'sets the block that is accessible via authenticate_admin' do
|
|
70
|
+
default_behaviour = 'default behaviour'
|
|
71
|
+
allow(Doorkeeper::Config).to receive(:head).and_return(default_behaviour)
|
|
72
|
+
|
|
73
|
+
Doorkeeper.configure do
|
|
74
|
+
orm DOORKEEPER_ORM
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
expect(subject.authenticate_admin.call({})).to eq(default_behaviour)
|
|
78
|
+
end
|
|
79
|
+
|
|
69
80
|
it 'sets the block that is accessible via authenticate_admin' do
|
|
70
81
|
block = proc {}
|
|
71
82
|
Doorkeeper.configure do
|
|
@@ -144,6 +155,24 @@ describe Doorkeeper, 'configuration' do
|
|
|
144
155
|
expect(subject.refresh_token_enabled?).to eq(true)
|
|
145
156
|
end
|
|
146
157
|
|
|
158
|
+
it 'can accept a boolean parameter' do
|
|
159
|
+
Doorkeeper.configure do
|
|
160
|
+
orm DOORKEEPER_ORM
|
|
161
|
+
use_refresh_token false
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
expect(subject.refresh_token_enabled?).to eq(false)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it 'can accept a block parameter' do
|
|
168
|
+
Doorkeeper.configure do
|
|
169
|
+
orm DOORKEEPER_ORM
|
|
170
|
+
use_refresh_token { |_context| nil }
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
expect(subject.refresh_token_enabled?).to be_a(Proc)
|
|
174
|
+
end
|
|
175
|
+
|
|
147
176
|
it "does not includes 'refresh_token' in authorization_response_types" do
|
|
148
177
|
expect(subject.token_grant_types).not_to include 'refresh_token'
|
|
149
178
|
end
|
|
@@ -119,6 +119,30 @@ module Doorkeeper::OAuth
|
|
|
119
119
|
)
|
|
120
120
|
expect(result.expires_in).to eql(500)
|
|
121
121
|
end
|
|
122
|
+
|
|
123
|
+
it "respects use_refresh_token with a block" do
|
|
124
|
+
server = double(:server,
|
|
125
|
+
access_token_expires_in: 100,
|
|
126
|
+
custom_access_token_expires_in: ->(_context) { nil },
|
|
127
|
+
refresh_token_enabled?: lambda { |context|
|
|
128
|
+
context.scopes == "public"
|
|
129
|
+
})
|
|
130
|
+
result = subject.find_or_create_access_token(
|
|
131
|
+
client,
|
|
132
|
+
"1",
|
|
133
|
+
"public",
|
|
134
|
+
server
|
|
135
|
+
)
|
|
136
|
+
expect(result.refresh_token).to_not be_nil
|
|
137
|
+
|
|
138
|
+
result = subject.find_or_create_access_token(
|
|
139
|
+
client,
|
|
140
|
+
"1",
|
|
141
|
+
"private",
|
|
142
|
+
server
|
|
143
|
+
)
|
|
144
|
+
expect(result.refresh_token).to be_nil
|
|
145
|
+
end
|
|
122
146
|
end
|
|
123
147
|
|
|
124
148
|
describe "#scopes" do
|
|
@@ -33,4 +33,47 @@ describe Doorkeeper::AccessGrant do
|
|
|
33
33
|
expect(subject).not_to be_valid
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
|
+
|
|
37
|
+
describe '.revoke_all_for' do
|
|
38
|
+
let(:resource_owner) { double(id: 100) }
|
|
39
|
+
let(:application) { FactoryBot.create :application }
|
|
40
|
+
let(:default_attributes) do
|
|
41
|
+
{
|
|
42
|
+
application: application,
|
|
43
|
+
resource_owner_id: resource_owner.id
|
|
44
|
+
}
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'revokes all tokens for given application and resource owner' do
|
|
48
|
+
FactoryBot.create :access_grant, default_attributes
|
|
49
|
+
|
|
50
|
+
described_class.revoke_all_for(application.id, resource_owner)
|
|
51
|
+
|
|
52
|
+
described_class.all.each do |token|
|
|
53
|
+
expect(token).to be_revoked
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'matches application' do
|
|
58
|
+
access_grant_for_different_app = FactoryBot.create(
|
|
59
|
+
:access_grant,
|
|
60
|
+
default_attributes.merge(application: FactoryBot.create(:application))
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
described_class.revoke_all_for(application.id, resource_owner)
|
|
64
|
+
|
|
65
|
+
expect(access_grant_for_different_app.reload).not_to be_revoked
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'matches resource owner' do
|
|
69
|
+
access_grant_for_different_owner = FactoryBot.create(
|
|
70
|
+
:access_grant,
|
|
71
|
+
default_attributes.merge(resource_owner_id: 90)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
described_class.revoke_all_for application.id, resource_owner
|
|
75
|
+
|
|
76
|
+
expect(access_grant_for_different_owner.reload).not_to be_revoked
|
|
77
|
+
end
|
|
78
|
+
end
|
|
36
79
|
end
|
|
@@ -306,15 +306,25 @@ module Doorkeeper
|
|
|
306
306
|
end
|
|
307
307
|
|
|
308
308
|
it 'matches application' do
|
|
309
|
-
|
|
309
|
+
access_token_for_different_app = FactoryBot.create(
|
|
310
|
+
:access_token,
|
|
311
|
+
default_attributes.merge(application: FactoryBot.create(:application))
|
|
312
|
+
)
|
|
313
|
+
|
|
310
314
|
AccessToken.revoke_all_for application.id, resource_owner
|
|
311
|
-
|
|
315
|
+
|
|
316
|
+
expect(access_token_for_different_app.reload).not_to be_revoked
|
|
312
317
|
end
|
|
313
318
|
|
|
314
319
|
it 'matches resource owner' do
|
|
315
|
-
FactoryBot.create
|
|
320
|
+
access_token_for_different_owner = FactoryBot.create(
|
|
321
|
+
:access_token,
|
|
322
|
+
default_attributes.merge(resource_owner_id: 90)
|
|
323
|
+
)
|
|
324
|
+
|
|
316
325
|
AccessToken.revoke_all_for application.id, resource_owner
|
|
317
|
-
|
|
326
|
+
|
|
327
|
+
expect(access_token_for_different_owner.reload).not_to be_revoked
|
|
318
328
|
end
|
|
319
329
|
end
|
|
320
330
|
|
|
@@ -440,8 +450,8 @@ module Doorkeeper
|
|
|
440
450
|
token = FactoryBot.create :access_token
|
|
441
451
|
token_hash = {
|
|
442
452
|
resource_owner_id: token.resource_owner_id,
|
|
443
|
-
|
|
444
|
-
|
|
453
|
+
scope: token.scopes,
|
|
454
|
+
expires_in: token.expires_in_seconds,
|
|
445
455
|
application: { uid: token.application.uid },
|
|
446
456
|
created_at: token.created_at.to_i
|
|
447
457
|
}
|
|
@@ -206,6 +206,19 @@ module Doorkeeper
|
|
|
206
206
|
end
|
|
207
207
|
end
|
|
208
208
|
|
|
209
|
+
describe :revoke_tokens_and_grants_for do
|
|
210
|
+
it 'revokes all access tokens and access grants' do
|
|
211
|
+
application_id = 42
|
|
212
|
+
resource_owner = double
|
|
213
|
+
expect(Doorkeeper::AccessToken).
|
|
214
|
+
to receive(:revoke_all_for).with(application_id, resource_owner)
|
|
215
|
+
expect(Doorkeeper::AccessGrant).
|
|
216
|
+
to receive(:revoke_all_for).with(application_id, resource_owner)
|
|
217
|
+
|
|
218
|
+
Application.revoke_tokens_and_grants_for(application_id, resource_owner)
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
209
222
|
describe :by_uid_and_secret do
|
|
210
223
|
context "when application is private/confidential" do
|
|
211
224
|
it "finds the application via uid/secret" do
|
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
|
3
3
|
feature 'Adding applications' do
|
|
4
4
|
context 'in application form' do
|
|
5
5
|
background do
|
|
6
|
+
i_am_logged_in
|
|
6
7
|
visit '/oauth/applications/new'
|
|
7
8
|
end
|
|
8
9
|
|
|
@@ -96,12 +97,15 @@ end
|
|
|
96
97
|
|
|
97
98
|
feature 'Listing applications' do
|
|
98
99
|
background do
|
|
100
|
+
i_am_logged_in
|
|
101
|
+
|
|
99
102
|
FactoryBot.create :application, name: 'Oauth Dude'
|
|
100
103
|
FactoryBot.create :application, name: 'Awesome App'
|
|
101
104
|
end
|
|
102
105
|
|
|
103
106
|
scenario 'application list' do
|
|
104
107
|
visit '/oauth/applications'
|
|
108
|
+
|
|
105
109
|
i_should_see 'Awesome App'
|
|
106
110
|
i_should_see 'Oauth Dude'
|
|
107
111
|
end
|
|
@@ -126,11 +130,14 @@ end
|
|
|
126
130
|
|
|
127
131
|
feature 'Show application' do
|
|
128
132
|
given :app do
|
|
133
|
+
i_am_logged_in
|
|
134
|
+
|
|
129
135
|
FactoryBot.create :application, name: 'Just another oauth app'
|
|
130
136
|
end
|
|
131
137
|
|
|
132
138
|
scenario 'visiting application page' do
|
|
133
139
|
visit "/oauth/applications/#{app.id}"
|
|
140
|
+
|
|
134
141
|
i_should_see 'Just another oauth app'
|
|
135
142
|
end
|
|
136
143
|
end
|
|
@@ -141,12 +148,15 @@ feature 'Edit application' do
|
|
|
141
148
|
end
|
|
142
149
|
|
|
143
150
|
background do
|
|
151
|
+
i_am_logged_in
|
|
152
|
+
|
|
144
153
|
visit "/oauth/applications/#{app.id}/edit"
|
|
145
154
|
end
|
|
146
155
|
|
|
147
156
|
scenario 'updating a valid app' do
|
|
148
157
|
fill_in 'doorkeeper_application[name]', with: 'Serious app'
|
|
149
158
|
click_button 'Submit'
|
|
159
|
+
|
|
150
160
|
i_should_see 'Application updated'
|
|
151
161
|
i_should_see 'Serious app'
|
|
152
162
|
i_should_not_see 'OMG my app'
|
|
@@ -155,21 +165,27 @@ feature 'Edit application' do
|
|
|
155
165
|
scenario 'updating an invalid app' do
|
|
156
166
|
fill_in 'doorkeeper_application[name]', with: ''
|
|
157
167
|
click_button 'Submit'
|
|
168
|
+
|
|
158
169
|
i_should_see 'Whoops! Check your form for possible errors'
|
|
159
170
|
end
|
|
160
171
|
end
|
|
161
172
|
|
|
162
173
|
feature 'Remove application' do
|
|
163
174
|
background do
|
|
175
|
+
i_am_logged_in
|
|
176
|
+
|
|
164
177
|
@app = FactoryBot.create :application
|
|
165
178
|
end
|
|
166
179
|
|
|
167
180
|
scenario 'deleting an application from list' do
|
|
168
181
|
visit '/oauth/applications'
|
|
182
|
+
|
|
169
183
|
i_should_see @app.name
|
|
184
|
+
|
|
170
185
|
within(:css, "tr#application_#{@app.id}") do
|
|
171
186
|
click_button 'Destroy'
|
|
172
187
|
end
|
|
188
|
+
|
|
173
189
|
i_should_see 'Application deleted'
|
|
174
190
|
i_should_not_see @app.name
|
|
175
191
|
end
|
|
@@ -177,6 +193,35 @@ feature 'Remove application' do
|
|
|
177
193
|
scenario 'deleting an application from show' do
|
|
178
194
|
visit "/oauth/applications/#{@app.id}"
|
|
179
195
|
click_button 'Destroy'
|
|
196
|
+
|
|
180
197
|
i_should_see 'Application deleted'
|
|
181
198
|
end
|
|
182
199
|
end
|
|
200
|
+
|
|
201
|
+
context 'when admin authenticator block is default' do
|
|
202
|
+
let(:app) { FactoryBot.create :application, name: 'app' }
|
|
203
|
+
|
|
204
|
+
feature 'application list' do
|
|
205
|
+
scenario 'fails with forbidden' do
|
|
206
|
+
visit '/oauth/applications'
|
|
207
|
+
|
|
208
|
+
should_have_status 403
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
feature 'adding an app' do
|
|
213
|
+
scenario 'fails with forbidden' do
|
|
214
|
+
visit '/oauth/applications/new'
|
|
215
|
+
|
|
216
|
+
should_have_status 403
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
feature 'editing an app' do
|
|
221
|
+
scenario 'fails with forbidden' do
|
|
222
|
+
visit "/oauth/applications/#{app.id}/edit"
|
|
223
|
+
|
|
224
|
+
should_have_status 403
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
end
|
|
@@ -54,7 +54,7 @@ feature 'Authorization Code Flow' do
|
|
|
54
54
|
should_not_have_json 'error'
|
|
55
55
|
|
|
56
56
|
should_have_json 'access_token', Doorkeeper::AccessToken.first.token
|
|
57
|
-
should_have_json 'token_type', '
|
|
57
|
+
should_have_json 'token_type', 'Bearer'
|
|
58
58
|
should_have_json_within 'expires_in', Doorkeeper::AccessToken.first.expires_in, 1
|
|
59
59
|
end
|
|
60
60
|
|
|
@@ -107,7 +107,7 @@ feature 'Authorization Code Flow' do
|
|
|
107
107
|
should_not_have_json 'error'
|
|
108
108
|
|
|
109
109
|
should_have_json 'access_token', Doorkeeper::AccessToken.first.token
|
|
110
|
-
should_have_json 'token_type', '
|
|
110
|
+
should_have_json 'token_type', 'Bearer'
|
|
111
111
|
should_have_json_within 'expires_in', Doorkeeper::AccessToken.first.expires_in, 1
|
|
112
112
|
end
|
|
113
113
|
|
|
@@ -150,7 +150,7 @@ feature 'Authorization Code Flow' do
|
|
|
150
150
|
should_not_have_json 'error'
|
|
151
151
|
|
|
152
152
|
should_have_json 'access_token', Doorkeeper::AccessToken.first.token
|
|
153
|
-
should_have_json 'token_type', '
|
|
153
|
+
should_have_json 'token_type', 'Bearer'
|
|
154
154
|
should_have_json_within 'expires_in', Doorkeeper::AccessToken.first.expires_in, 1
|
|
155
155
|
end
|
|
156
156
|
|
|
@@ -185,7 +185,7 @@ feature 'Authorization Code Flow' do
|
|
|
185
185
|
should_not_have_json 'error'
|
|
186
186
|
|
|
187
187
|
should_have_json 'access_token', Doorkeeper::AccessToken.first.token
|
|
188
|
-
should_have_json 'token_type', '
|
|
188
|
+
should_have_json 'token_type', 'Bearer'
|
|
189
189
|
should_have_json_within 'expires_in', Doorkeeper::AccessToken.first.expires_in, 1
|
|
190
190
|
end
|
|
191
191
|
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
module RequestSpecHelper
|
|
2
|
+
def i_am_logged_in
|
|
3
|
+
allow(Doorkeeper.configuration).to receive(:authenticate_admin).and_return(->(*) {})
|
|
4
|
+
end
|
|
5
|
+
|
|
2
6
|
def i_should_see(content)
|
|
3
7
|
expect(page).to have_content(content)
|
|
4
8
|
end
|
|
@@ -39,6 +43,10 @@ module RequestSpecHelper
|
|
|
39
43
|
expect(headers[header]).to eq(value)
|
|
40
44
|
end
|
|
41
45
|
|
|
46
|
+
def should_have_status(status)
|
|
47
|
+
expect(page.driver.response.status).to eq(status)
|
|
48
|
+
end
|
|
49
|
+
|
|
42
50
|
def with_access_token_header(token)
|
|
43
51
|
with_header 'Authorization', "Bearer #{token}"
|
|
44
52
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: doorkeeper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.0.0
|
|
4
|
+
version: 5.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Felipe Elias Philipp
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2018-
|
|
14
|
+
date: 2018-08-24 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: railties
|
|
@@ -31,16 +31,16 @@ dependencies:
|
|
|
31
31
|
name: capybara
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
|
33
33
|
requirements:
|
|
34
|
-
- - "
|
|
34
|
+
- - "~>"
|
|
35
35
|
- !ruby/object:Gem::Version
|
|
36
|
-
version: '
|
|
36
|
+
version: '2.18'
|
|
37
37
|
type: :development
|
|
38
38
|
prerelease: false
|
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
40
|
requirements:
|
|
41
|
-
- - "
|
|
41
|
+
- - "~>"
|
|
42
42
|
- !ruby/object:Gem::Version
|
|
43
|
-
version: '
|
|
43
|
+
version: '2.18'
|
|
44
44
|
- !ruby/object:Gem::Dependency
|
|
45
45
|
name: coveralls
|
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -150,6 +150,7 @@ files:
|
|
|
150
150
|
- ".github/ISSUE_TEMPLATE.md"
|
|
151
151
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
|
152
152
|
- ".gitignore"
|
|
153
|
+
- ".gitlab-ci.yml"
|
|
153
154
|
- ".hound.yml"
|
|
154
155
|
- ".rspec"
|
|
155
156
|
- ".rubocop.yml"
|
|
@@ -164,6 +165,7 @@ files:
|
|
|
164
165
|
- RELEASING.md
|
|
165
166
|
- Rakefile
|
|
166
167
|
- SECURITY.md
|
|
168
|
+
- UPGRADE.md
|
|
167
169
|
- app/assets/stylesheets/doorkeeper/admin/application.css
|
|
168
170
|
- app/assets/stylesheets/doorkeeper/application.css
|
|
169
171
|
- app/controllers/doorkeeper/application_controller.rb
|
|
@@ -425,9 +427,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
425
427
|
version: '2.1'
|
|
426
428
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
427
429
|
requirements:
|
|
428
|
-
- - "
|
|
430
|
+
- - ">="
|
|
429
431
|
- !ruby/object:Gem::Version
|
|
430
|
-
version:
|
|
432
|
+
version: '0'
|
|
431
433
|
requirements: []
|
|
432
434
|
rubyforge_project:
|
|
433
435
|
rubygems_version: 2.6.11
|