doorkeeper 1.1.0 → 1.2.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.
Potentially problematic release.
This version of doorkeeper might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +14 -2
- data/README.md +93 -42
- data/app/controllers/doorkeeper/application_controller.rb +1 -1
- data/app/controllers/doorkeeper/applications_controller.rb +4 -4
- data/app/controllers/doorkeeper/authorizations_controller.rb +3 -3
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +1 -1
- data/app/controllers/doorkeeper/token_info_controller.rb +3 -3
- data/app/controllers/doorkeeper/tokens_controller.rb +29 -2
- data/app/helpers/doorkeeper/form_errors_helper.rb +2 -2
- data/app/validators/redirect_uri_validator.rb +1 -1
- data/app/views/doorkeeper/applications/_form.html.erb +3 -3
- data/app/views/doorkeeper/applications/edit.html.erb +1 -1
- data/app/views/doorkeeper/applications/new.html.erb +1 -1
- data/app/views/doorkeeper/applications/show.html.erb +1 -1
- data/app/views/doorkeeper/authorizations/new.html.erb +5 -5
- data/doorkeeper.gemspec +1 -1
- data/lib/doorkeeper.rb +31 -31
- data/lib/doorkeeper/config.rb +66 -37
- data/lib/doorkeeper/doorkeeper_for.rb +6 -3
- data/lib/doorkeeper/engine.rb +2 -2
- data/lib/doorkeeper/helpers/controller.rb +9 -9
- data/lib/doorkeeper/helpers/filter.rb +1 -1
- data/lib/doorkeeper/models/access_grant.rb +5 -5
- data/lib/doorkeeper/models/access_token.rb +22 -18
- data/lib/doorkeeper/models/active_record/access_token.rb +8 -8
- data/lib/doorkeeper/models/active_record/application.rb +5 -5
- data/lib/doorkeeper/models/application.rb +8 -9
- data/lib/doorkeeper/models/expirable.rb +1 -1
- data/lib/doorkeeper/models/mongo_mapper/access_grant.rb +2 -2
- data/lib/doorkeeper/models/mongo_mapper/access_token.rb +11 -11
- data/lib/doorkeeper/models/mongo_mapper/application.rb +4 -4
- data/lib/doorkeeper/models/mongoid/version.rb +2 -2
- data/lib/doorkeeper/models/mongoid2/access_grant.rb +7 -7
- data/lib/doorkeeper/models/mongoid2/access_token.rb +14 -14
- data/lib/doorkeeper/models/mongoid2/application.rb +7 -7
- data/lib/doorkeeper/models/mongoid3_4/access_grant.rb +7 -7
- data/lib/doorkeeper/models/mongoid3_4/access_token.rb +13 -13
- data/lib/doorkeeper/models/mongoid3_4/application.rb +6 -6
- data/lib/doorkeeper/models/ownership.rb +5 -5
- data/lib/doorkeeper/oauth/authorization/code.rb +5 -5
- data/lib/doorkeeper/oauth/authorization/token.rb +7 -7
- data/lib/doorkeeper/oauth/authorization_code_request.rb +18 -19
- data/lib/doorkeeper/oauth/client.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +4 -4
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +6 -4
- data/lib/doorkeeper/oauth/client_credentials/validation.rb +2 -2
- data/lib/doorkeeper/oauth/client_credentials_request.rb +11 -15
- data/lib/doorkeeper/oauth/code_request.rb +5 -4
- data/lib/doorkeeper/oauth/code_response.rb +8 -7
- data/lib/doorkeeper/oauth/error.rb +1 -1
- data/lib/doorkeeper/oauth/error_response.rb +5 -5
- data/lib/doorkeeper/oauth/helpers/uri_checker.rb +1 -1
- data/lib/doorkeeper/oauth/invalid_token_response.rb +10 -10
- data/lib/doorkeeper/oauth/password_access_token_request.rb +57 -54
- data/lib/doorkeeper/oauth/pre_authorization.rb +7 -7
- data/lib/doorkeeper/oauth/refresh_token_request.rb +27 -24
- data/lib/doorkeeper/oauth/scopes.rb +3 -3
- data/lib/doorkeeper/oauth/token.rb +27 -1
- data/lib/doorkeeper/oauth/token_request.rb +14 -4
- data/lib/doorkeeper/rails/routes.rb +31 -22
- data/lib/doorkeeper/rails/routes/mapping.rb +11 -12
- data/lib/doorkeeper/request.rb +5 -5
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/generators/doorkeeper/application_owner_generator.rb +1 -1
- data/lib/generators/doorkeeper/install_generator.rb +5 -5
- data/lib/generators/doorkeeper/migration_generator.rb +1 -1
- data/lib/generators/doorkeeper/mongo_mapper/indexes_generator.rb +2 -2
- data/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb +2 -2
- data/lib/generators/doorkeeper/templates/initializer.rb +16 -3
- data/lib/generators/doorkeeper/templates/migration.rb +16 -17
- data/lib/generators/doorkeeper/views_generator.rb +1 -1
- data/spec/controllers/applications_controller_spec.rb +7 -7
- data/spec/controllers/authorizations_controller_spec.rb +48 -48
- data/spec/controllers/protected_resources_controller_spec.rb +108 -107
- data/spec/controllers/token_info_controller_spec.rb +11 -11
- data/spec/controllers/tokens_controller_spec.rb +8 -8
- data/spec/dummy/app/controllers/custom_authorizations_controller.rb +2 -2
- data/spec/dummy/app/controllers/full_protected_resources_controller.rb +3 -3
- data/spec/dummy/app/controllers/home_controller.rb +5 -5
- data/spec/dummy/app/controllers/metal_controller.rb +1 -1
- data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +2 -2
- data/spec/dummy/app/models/user.rb +3 -3
- data/spec/dummy/config/application.rb +8 -9
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/doorkeeper.rb +5 -5
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
- data/spec/dummy/config/routes.rb +27 -27
- data/spec/dummy/db/migrate/20130902165751_create_doorkeeper_tables.rb +16 -17
- data/spec/dummy/db/migrate/20130902175349_add_owner_to_application.rb +3 -3
- data/spec/dummy/db/schema.rb +39 -39
- data/spec/factories/access_grant.rb +3 -3
- data/spec/factories/access_token.rb +1 -1
- data/spec/factories/application.rb +3 -3
- data/spec/generators/application_owner_generator_spec.rb +6 -7
- data/spec/generators/install_generator_spec.rb +9 -9
- data/spec/generators/migration_generator_spec.rb +4 -4
- data/spec/lib/config_spec.rb +136 -44
- data/spec/lib/models/expirable_spec.rb +9 -9
- data/spec/lib/models/revocable_spec.rb +4 -4
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +4 -4
- data/spec/lib/oauth/authorization_code_request_spec.rb +2 -2
- data/spec/lib/oauth/client/credentials_spec.rb +4 -4
- data/spec/lib/oauth/client/methods_spec.rb +10 -10
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +9 -7
- data/spec/lib/oauth/client_credentials/validation_spec.rb +2 -2
- data/spec/lib/oauth/client_credentials_request_spec.rb +6 -6
- data/spec/lib/oauth/client_spec.rb +4 -4
- data/spec/lib/oauth/code_request_spec.rb +10 -9
- data/spec/lib/oauth/error_response_spec.rb +8 -8
- data/spec/lib/oauth/error_spec.rb +1 -1
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +17 -17
- data/spec/lib/oauth/helpers/unique_token_spec.rb +7 -7
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +33 -33
- data/spec/lib/oauth/invalid_token_response_spec.rb +4 -4
- data/spec/lib/oauth/password_access_token_request_spec.rb +13 -13
- data/spec/lib/oauth/pre_authorization_spec.rb +47 -7
- data/spec/lib/oauth/refresh_token_request_spec.rb +11 -21
- data/spec/lib/oauth/scopes_spec.rb +32 -32
- data/spec/lib/oauth/token_request_spec.rb +10 -9
- data/spec/lib/oauth/token_response_spec.rb +13 -15
- data/spec/lib/oauth/token_spec.rb +24 -10
- data/spec/lib/server_spec.rb +24 -2
- data/spec/models/doorkeeper/access_grant_spec.rb +8 -8
- data/spec/models/doorkeeper/access_token_spec.rb +79 -33
- data/spec/models/doorkeeper/application_spec.rb +29 -29
- data/spec/requests/applications/applications_request_spec.rb +15 -15
- data/spec/requests/applications/authorized_applications_spec.rb +7 -7
- data/spec/requests/endpoints/authorization_spec.rb +19 -12
- data/spec/requests/endpoints/token_spec.rb +26 -8
- data/spec/requests/flows/authorization_code_errors_spec.rb +17 -17
- data/spec/requests/flows/authorization_code_spec.rb +28 -28
- data/spec/requests/flows/client_credentials_spec.rb +3 -3
- data/spec/requests/flows/implicit_grant_errors_spec.rb +5 -5
- data/spec/requests/flows/implicit_grant_spec.rb +2 -2
- data/spec/requests/flows/password_spec.rb +32 -32
- data/spec/requests/flows/refresh_token_spec.rb +23 -23
- data/spec/requests/flows/revoke_token_spec.rb +165 -0
- data/spec/requests/flows/skip_authorization_spec.rb +10 -10
- data/spec/requests/protected_resources/metal_spec.rb +1 -1
- data/spec/requests/protected_resources/private_api_spec.rb +5 -5
- data/spec/routing/custom_controller_routes_spec.rb +4 -0
- data/spec/routing/default_routes_spec.rb +5 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/spec_helper_integration.rb +8 -10
- data/spec/support/helpers/access_token_request_helper.rb +3 -3
- data/spec/support/helpers/authorization_request_helper.rb +3 -3
- data/spec/support/helpers/config_helper.rb +1 -1
- data/spec/support/helpers/model_helper.rb +2 -2
- data/spec/support/helpers/request_spec_helper.rb +3 -3
- data/spec/support/helpers/url_helper.rb +25 -21
- data/spec/support/orm/active_record.rb +4 -4
- data/spec/support/orm/mongo_mapper.rb +2 -3
- data/spec/support/orm/mongoid.rb +5 -6
- data/spec/support/shared/controllers_shared_context.rb +15 -15
- data/spec/support/shared/models_shared_examples.rb +13 -13
- data/spec/validators/redirect_uri_validator_spec.rb +9 -9
- metadata +5 -4
@@ -14,17 +14,17 @@ feature 'Implicit Grant Flow Errors' do
|
|
14
14
|
|
15
15
|
[
|
16
16
|
[:client_id, :invalid_client],
|
17
|
-
[:redirect_uri, :invalid_redirect_uri]
|
17
|
+
[:redirect_uri, :invalid_redirect_uri]
|
18
18
|
].each do |error|
|
19
19
|
scenario "displays #{error.last.inspect} error for invalid #{error.first.inspect}" do
|
20
|
-
visit authorization_endpoint_url(:
|
21
|
-
i_should_not_see
|
20
|
+
visit authorization_endpoint_url(client: @client, error.first => 'invalid', response_type: 'token')
|
21
|
+
i_should_not_see 'Authorize'
|
22
22
|
i_should_see_translated_error_message error.last
|
23
23
|
end
|
24
24
|
|
25
25
|
scenario "displays #{error.last.inspect} error when #{error.first.inspect} is missing" do
|
26
|
-
visit authorization_endpoint_url(:
|
27
|
-
i_should_not_see
|
26
|
+
visit authorization_endpoint_url(client: @client, error.first => '', response_type: 'token')
|
27
|
+
i_should_not_see 'Authorize'
|
28
28
|
i_should_see_translated_error_message error.last
|
29
29
|
end
|
30
30
|
end
|
@@ -9,8 +9,8 @@ feature 'Implicit Grant Flow' do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
scenario 'resource owner authorizes the client' do
|
12
|
-
visit authorization_endpoint_url(:
|
13
|
-
click_on
|
12
|
+
visit authorization_endpoint_url(client: @client, response_type: 'token')
|
13
|
+
click_on 'Authorize'
|
14
14
|
|
15
15
|
access_token_should_exist_for @client, @resource_owner
|
16
16
|
|
@@ -12,11 +12,11 @@ feature 'Resource Owner Password Credentials Flow inproperly set up' do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'with valid user credentials' do
|
15
|
-
scenario
|
15
|
+
scenario 'should issue new token' do
|
16
16
|
pending 'Check a way to supress warnings here (or handle config better)'
|
17
|
-
expect
|
18
|
-
post password_token_endpoint_url(:
|
19
|
-
|
17
|
+
expect do
|
18
|
+
post password_token_endpoint_url(client: @client, resource_owner: @resource_owner)
|
19
|
+
end.to_not change { Doorkeeper::AccessToken.count }
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -29,30 +29,30 @@ feature 'Resource Owner Password Credentials Flow' do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
context 'with valid user credentials' do
|
32
|
-
scenario
|
33
|
-
expect
|
34
|
-
post password_token_endpoint_url(:
|
35
|
-
|
32
|
+
scenario 'should issue new token' do
|
33
|
+
expect do
|
34
|
+
post password_token_endpoint_url(client: @client, resource_owner: @resource_owner)
|
35
|
+
end.to change { Doorkeeper::AccessToken.count }.by(1)
|
36
36
|
|
37
37
|
token = Doorkeeper::AccessToken.first
|
38
38
|
|
39
39
|
should_have_json 'access_token', token.token
|
40
40
|
end
|
41
41
|
|
42
|
-
scenario
|
43
|
-
expect
|
44
|
-
post password_token_endpoint_url(:
|
45
|
-
|
42
|
+
scenario 'should issue new token without client credentials' do
|
43
|
+
expect do
|
44
|
+
post password_token_endpoint_url(resource_owner: @resource_owner)
|
45
|
+
end.to change { Doorkeeper::AccessToken.count }.by(1)
|
46
46
|
|
47
47
|
token = Doorkeeper::AccessToken.first
|
48
48
|
|
49
49
|
should_have_json 'access_token', token.token
|
50
50
|
end
|
51
51
|
|
52
|
-
scenario
|
52
|
+
scenario 'should issue a refresh token if enabled' do
|
53
53
|
config_is_set(:refresh_token_enabled, true)
|
54
54
|
|
55
|
-
post password_token_endpoint_url(:
|
55
|
+
post password_token_endpoint_url(client: @client, resource_owner: @resource_owner)
|
56
56
|
|
57
57
|
token = Doorkeeper::AccessToken.first
|
58
58
|
|
@@ -60,29 +60,29 @@ feature 'Resource Owner Password Credentials Flow' do
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
context
|
64
|
-
scenario
|
65
|
-
expect
|
66
|
-
post password_token_endpoint_url(
|
67
|
-
|
68
|
-
|
69
|
-
|
63
|
+
context 'with invalid user credentials' do
|
64
|
+
scenario 'should not issue new token with bad password' do
|
65
|
+
expect do
|
66
|
+
post password_token_endpoint_url(client: @client,
|
67
|
+
resource_owner_username: @resource_owner.name,
|
68
|
+
resource_owner_password: 'wrongpassword')
|
69
|
+
end.to_not change { Doorkeeper::AccessToken.count }
|
70
70
|
end
|
71
71
|
|
72
|
-
scenario
|
73
|
-
expect
|
74
|
-
post password_token_endpoint_url(
|
75
|
-
|
72
|
+
scenario 'should not issue new token without credentials' do
|
73
|
+
expect do
|
74
|
+
post password_token_endpoint_url(client: @client)
|
75
|
+
end.to_not change { Doorkeeper::AccessToken.count }
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
context
|
80
|
-
scenario
|
81
|
-
expect
|
82
|
-
post password_token_endpoint_url(
|
83
|
-
|
84
|
-
|
85
|
-
|
79
|
+
context 'with invalid client credentials' do
|
80
|
+
scenario 'should not issue new token with bad client credentials' do
|
81
|
+
expect do
|
82
|
+
post password_token_endpoint_url(client_id: @client.uid,
|
83
|
+
client_secret: 'bad_secret',
|
84
|
+
resource_owner: @resource_owner)
|
85
|
+
end.to_not change { Doorkeeper::AccessToken.count }
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
require 'spec_helper_integration'
|
2
2
|
|
3
|
-
feature
|
3
|
+
feature 'Refresh Token Flow' do
|
4
4
|
before do
|
5
|
-
Doorkeeper.configure
|
5
|
+
Doorkeeper.configure do
|
6
6
|
orm DOORKEEPER_ORM
|
7
7
|
use_refresh_token
|
8
|
-
|
8
|
+
end
|
9
9
|
client_exists
|
10
10
|
end
|
11
11
|
|
12
|
-
context
|
12
|
+
context 'issuing a refresh token' do
|
13
13
|
before do
|
14
|
-
authorization_code_exists :
|
14
|
+
authorization_code_exists application: @client
|
15
15
|
end
|
16
16
|
|
17
|
-
scenario
|
18
|
-
post token_endpoint_url(:
|
17
|
+
scenario 'client gets the refresh token and refreshses it' do
|
18
|
+
post token_endpoint_url(code: @authorization.token, client: @client)
|
19
19
|
|
20
20
|
token = Doorkeeper::AccessToken.first
|
21
21
|
|
@@ -24,7 +24,7 @@ feature "Refresh Token Flow" do
|
|
24
24
|
|
25
25
|
expect(@authorization.reload).to be_revoked
|
26
26
|
|
27
|
-
post refresh_token_endpoint_url(:
|
27
|
+
post refresh_token_endpoint_url(client: @client, refresh_token: token.refresh_token)
|
28
28
|
|
29
29
|
new_token = Doorkeeper::AccessToken.last
|
30
30
|
should_have_json 'access_token', new_token.token
|
@@ -35,52 +35,52 @@ feature "Refresh Token Flow" do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
context
|
38
|
+
context 'refreshing the token' do
|
39
39
|
before do
|
40
|
-
@token = FactoryGirl.create(:access_token, :
|
40
|
+
@token = FactoryGirl.create(:access_token, application: @client, resource_owner_id: 1, use_refresh_token: true)
|
41
41
|
end
|
42
42
|
|
43
|
-
scenario
|
44
|
-
post refresh_token_endpoint_url(:
|
43
|
+
scenario 'client request a token with refresh token' do
|
44
|
+
post refresh_token_endpoint_url(client: @client, refresh_token: @token.refresh_token)
|
45
45
|
should_have_json 'refresh_token', Doorkeeper::AccessToken.last.refresh_token
|
46
46
|
expect(@token.reload).to be_revoked
|
47
47
|
end
|
48
48
|
|
49
|
-
scenario
|
49
|
+
scenario 'client request a token with expired access token' do
|
50
50
|
@token.update_column :expires_in, -100
|
51
|
-
post refresh_token_endpoint_url(:
|
51
|
+
post refresh_token_endpoint_url(client: @client, refresh_token: @token.refresh_token)
|
52
52
|
should_have_json 'refresh_token', Doorkeeper::AccessToken.last.refresh_token
|
53
53
|
expect(@token.reload).to be_revoked
|
54
54
|
end
|
55
55
|
|
56
56
|
# TODO: verify proper error code for this (previously was invalid_grant)
|
57
|
-
scenario
|
58
|
-
post refresh_token_endpoint_url(:
|
57
|
+
scenario 'client gets an error for invalid refresh token' do
|
58
|
+
post refresh_token_endpoint_url(client: @client, refresh_token: 'invalid')
|
59
59
|
should_not_have_json 'refresh_token'
|
60
60
|
should_have_json 'error', 'invalid_request'
|
61
61
|
end
|
62
62
|
|
63
63
|
# TODO: verify proper error code for this (previously was invalid_grant)
|
64
|
-
scenario
|
64
|
+
scenario 'client gets an error for revoked acccess token' do
|
65
65
|
@token.revoke
|
66
|
-
post refresh_token_endpoint_url(:
|
66
|
+
post refresh_token_endpoint_url(client: @client, refresh_token: @token.refresh_token)
|
67
67
|
should_not_have_json 'refresh_token'
|
68
68
|
should_have_json 'error', 'invalid_request'
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
context
|
72
|
+
context 'refreshing the token with multiple sessions (devices)' do
|
73
73
|
before do
|
74
74
|
# enable password auth to simulate other devices
|
75
75
|
config_is_set(:resource_owner_from_credentials) { User.authenticate! params[:username], params[:password] }
|
76
76
|
create_resource_owner
|
77
|
-
@token = FactoryGirl.create(:access_token, :
|
77
|
+
@token = FactoryGirl.create(:access_token, application: @client, resource_owner_id: @resource_owner.id, use_refresh_token: true)
|
78
78
|
end
|
79
79
|
|
80
|
-
scenario
|
80
|
+
scenario 'client request a token after creating another token with the same user' do
|
81
81
|
@token.update_column :expires_in, -100
|
82
|
-
post password_token_endpoint_url(:
|
83
|
-
post refresh_token_endpoint_url(:
|
82
|
+
post password_token_endpoint_url(client: @client, resource_owner: @resource_owner)
|
83
|
+
post refresh_token_endpoint_url(client: @client, refresh_token: @token.refresh_token)
|
84
84
|
should_have_json 'refresh_token', Doorkeeper::AccessToken.last.refresh_token
|
85
85
|
expect(@token.reload).to be_revoked
|
86
86
|
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'spec_helper_integration'
|
2
|
+
|
3
|
+
feature 'Revoke Token Flow' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Doorkeeper.configure { orm DOORKEEPER_ORM }
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'with default parameters' do
|
10
|
+
|
11
|
+
let(:client_application) { FactoryGirl.create :application }
|
12
|
+
let(:resource_owner) { User.create!(name: 'John', password: 'sekret') }
|
13
|
+
let(:authorization_access_token) do
|
14
|
+
FactoryGirl.create(:access_token,
|
15
|
+
application: client_application,
|
16
|
+
resource_owner_id: resource_owner.id,
|
17
|
+
use_refresh_token: true)
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:headers) { { 'HTTP_AUTHORIZATION' => "Bearer #{authorization_access_token.token}" } }
|
21
|
+
|
22
|
+
context 'With invalid token to revoke' do
|
23
|
+
|
24
|
+
scenario 'client wants to revoke the given access token' do
|
25
|
+
|
26
|
+
post revocation_token_endpoint_url, { token: 'I_AM_AN_INVALIDE_TOKEN' }, headers
|
27
|
+
|
28
|
+
authorization_access_token.reload
|
29
|
+
# The authorization server responds with HTTP status code 200 if the token
|
30
|
+
# has been revoked successfully or if the client submitted an invalid token.
|
31
|
+
expect(response).to be_success
|
32
|
+
expect(authorization_access_token).to_not be_revoked
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'The access token to revoke is the same than the authorization access token' do
|
37
|
+
|
38
|
+
let(:token_to_revoke) { authorization_access_token }
|
39
|
+
|
40
|
+
scenario 'client wants to revoke the given access token' do
|
41
|
+
|
42
|
+
post revocation_token_endpoint_url, { token: token_to_revoke.token }, headers
|
43
|
+
|
44
|
+
token_to_revoke.reload
|
45
|
+
authorization_access_token.reload
|
46
|
+
|
47
|
+
expect(response).to be_success
|
48
|
+
expect(token_to_revoke.revoked?).to be_true
|
49
|
+
expect(Doorkeeper::AccessToken.by_refresh_token(token_to_revoke.refresh_token).revoked?).to be_true
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
scenario 'client wants to revoke the given access token using the POST query string' do
|
54
|
+
|
55
|
+
url_with_query_string = revocation_token_endpoint_url + '?' + Rack::Utils.build_query(token: token_to_revoke.token)
|
56
|
+
post url_with_query_string, {}, headers
|
57
|
+
|
58
|
+
token_to_revoke.reload
|
59
|
+
authorization_access_token.reload
|
60
|
+
|
61
|
+
expect(response).to be_success
|
62
|
+
expect(token_to_revoke.revoked?).to be_false
|
63
|
+
expect(Doorkeeper::AccessToken.by_refresh_token(token_to_revoke.refresh_token).revoked?).to be_false
|
64
|
+
expect(authorization_access_token.revoked?).to be_false
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'The access token to revoke app and owners are the same than the authorization access token' do
|
71
|
+
|
72
|
+
let(:token_to_revoke) do
|
73
|
+
FactoryGirl.create(:access_token,
|
74
|
+
application: client_application,
|
75
|
+
resource_owner_id: resource_owner.id,
|
76
|
+
use_refresh_token: true)
|
77
|
+
end
|
78
|
+
|
79
|
+
scenario 'client wants to revoke the given access token' do
|
80
|
+
|
81
|
+
post revocation_token_endpoint_url, { token: token_to_revoke.token }, headers
|
82
|
+
|
83
|
+
token_to_revoke.reload
|
84
|
+
authorization_access_token.reload
|
85
|
+
|
86
|
+
expect(response).to be_success
|
87
|
+
expect(token_to_revoke.revoked?).to be_true
|
88
|
+
expect(Doorkeeper::AccessToken.by_refresh_token(token_to_revoke.refresh_token).revoked?).to be_true
|
89
|
+
expect(authorization_access_token.revoked?).to be_false
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'The access token to revoke authorization owner is the same than the authorization access token' do
|
95
|
+
|
96
|
+
let(:other_client_application) { FactoryGirl.create :application }
|
97
|
+
let(:token_to_revoke) do
|
98
|
+
FactoryGirl.create(:access_token,
|
99
|
+
application: other_client_application,
|
100
|
+
resource_owner_id: resource_owner.id,
|
101
|
+
use_refresh_token: true)
|
102
|
+
end
|
103
|
+
|
104
|
+
scenario 'client wants to revoke the given access token' do
|
105
|
+
|
106
|
+
post revocation_token_endpoint_url, { token: token_to_revoke.token }, headers
|
107
|
+
|
108
|
+
token_to_revoke.reload
|
109
|
+
authorization_access_token.reload
|
110
|
+
|
111
|
+
expect(response).to be_success
|
112
|
+
expect(token_to_revoke.revoked?).to be_false
|
113
|
+
expect(Doorkeeper::AccessToken.by_refresh_token(token_to_revoke.refresh_token).revoked?).to be_false
|
114
|
+
expect(authorization_access_token.revoked?).to be_false
|
115
|
+
|
116
|
+
end
|
117
|
+
end
|
118
|
+
context 'The access token to revoke app is the same than the authorization access token' do
|
119
|
+
|
120
|
+
let(:other_resource_owner) { User.create!(name: 'Matheo', password: 'pareto') }
|
121
|
+
let(:token_to_revoke) do
|
122
|
+
FactoryGirl.create(:access_token,
|
123
|
+
application: client_application,
|
124
|
+
resource_owner_id: other_resource_owner.id,
|
125
|
+
use_refresh_token: true)
|
126
|
+
end
|
127
|
+
|
128
|
+
scenario 'client wants to revoke the given access token' do
|
129
|
+
|
130
|
+
post revocation_token_endpoint_url, { token: token_to_revoke.token }, headers
|
131
|
+
|
132
|
+
token_to_revoke.reload
|
133
|
+
authorization_access_token.reload
|
134
|
+
|
135
|
+
expect(response).to be_success
|
136
|
+
expect(token_to_revoke.revoked?).to be_false
|
137
|
+
expect(Doorkeeper::AccessToken.by_refresh_token(token_to_revoke.refresh_token).revoked?).to be_false
|
138
|
+
expect(authorization_access_token.revoked?).to be_false
|
139
|
+
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context 'With valid refresh token to revoke' do
|
144
|
+
|
145
|
+
let(:token_to_revoke) do
|
146
|
+
FactoryGirl.create(:access_token,
|
147
|
+
application: client_application,
|
148
|
+
resource_owner_id: resource_owner.id,
|
149
|
+
use_refresh_token: true)
|
150
|
+
end
|
151
|
+
|
152
|
+
scenario 'client wants to revoke the given refresh token' do
|
153
|
+
|
154
|
+
post revocation_token_endpoint_url, { token: token_to_revoke.refresh_token, token_type_hint: 'refresh_token' }, headers
|
155
|
+
authorization_access_token.reload
|
156
|
+
token_to_revoke.reload
|
157
|
+
|
158
|
+
expect(response).to be_success
|
159
|
+
expect(Doorkeeper::AccessToken.by_refresh_token(token_to_revoke.refresh_token).revoked?).to be_true
|
160
|
+
expect(authorization_access_token).to_not be_revoked
|
161
|
+
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -15,25 +15,25 @@ feature 'Skip authorization form' do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
scenario 'skips the authorization and return a new grant code' do
|
18
|
-
client_is_authorized(@client, @resource_owner, :
|
19
|
-
visit authorization_endpoint_url(:
|
18
|
+
client_is_authorized(@client, @resource_owner, scopes: 'public')
|
19
|
+
visit authorization_endpoint_url(client: @client)
|
20
20
|
|
21
|
-
i_should_not_see
|
21
|
+
i_should_not_see 'Authorize'
|
22
22
|
client_should_be_authorized @client
|
23
23
|
i_should_be_on_client_callback @client
|
24
|
-
url_should_have_param
|
24
|
+
url_should_have_param 'code', Doorkeeper::AccessGrant.first.token
|
25
25
|
end
|
26
26
|
|
27
27
|
scenario 'does not skip authorization when scopes differ' do
|
28
|
-
client_is_authorized(@client, @resource_owner, :
|
29
|
-
visit authorization_endpoint_url(:
|
30
|
-
i_should_see
|
28
|
+
client_is_authorized(@client, @resource_owner, scopes: 'public write')
|
29
|
+
visit authorization_endpoint_url(client: @client, scope: 'public')
|
30
|
+
i_should_see 'Authorize'
|
31
31
|
end
|
32
32
|
|
33
33
|
scenario 'creates grant with new scope when scopes differ' do
|
34
|
-
client_is_authorized(@client, @resource_owner, :
|
35
|
-
visit authorization_endpoint_url(:
|
36
|
-
click_on
|
34
|
+
client_is_authorized(@client, @resource_owner, scopes: 'public write')
|
35
|
+
visit authorization_endpoint_url(client: @client, scope: 'public')
|
36
|
+
click_on 'Authorize'
|
37
37
|
access_grant_should_have_scopes :public
|
38
38
|
end
|
39
39
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper_integration'
|
|
3
3
|
feature 'ActionController::Metal API' do
|
4
4
|
background do
|
5
5
|
@client = FactoryGirl.create(:application)
|
6
|
-
@resource = User.create!(:
|
6
|
+
@resource = User.create!(name: 'Joe', password: 'sekret')
|
7
7
|
@token = client_is_authorized(@client, @resource)
|
8
8
|
end
|
9
9
|
|