doorkeeper 5.3.3 → 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of doorkeeper might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +82 -4
- data/README.md +6 -4
- data/app/controllers/doorkeeper/applications_controller.rb +4 -4
- data/app/controllers/doorkeeper/authorizations_controller.rb +31 -12
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +2 -2
- data/app/controllers/doorkeeper/tokens_controller.rb +57 -20
- data/app/views/doorkeeper/applications/_form.html.erb +1 -1
- data/app/views/doorkeeper/applications/show.html.erb +19 -2
- data/config/locales/en.yml +3 -1
- data/lib/doorkeeper/config/abstract_builder.rb +28 -0
- data/lib/doorkeeper/config/option.rb +28 -14
- data/lib/doorkeeper/config.rb +64 -35
- data/lib/doorkeeper/engine.rb +1 -1
- data/lib/doorkeeper/grape/helpers.rb +1 -1
- data/lib/doorkeeper/helpers/controller.rb +4 -4
- data/lib/doorkeeper/models/access_grant_mixin.rb +20 -16
- data/lib/doorkeeper/models/access_token_mixin.rb +108 -45
- data/lib/doorkeeper/models/application_mixin.rb +5 -4
- data/lib/doorkeeper/models/concerns/resource_ownerable.rb +47 -0
- data/lib/doorkeeper/models/concerns/revocable.rb +1 -1
- data/lib/doorkeeper/models/concerns/scopes.rb +5 -1
- data/lib/doorkeeper/models/concerns/secret_storable.rb +1 -3
- data/lib/doorkeeper/oauth/authorization/code.rb +15 -6
- data/lib/doorkeeper/oauth/authorization/context.rb +2 -2
- data/lib/doorkeeper/oauth/authorization/token.rb +8 -12
- data/lib/doorkeeper/oauth/authorization/uri_builder.rb +4 -4
- data/lib/doorkeeper/oauth/authorization_code_request.rb +18 -8
- data/lib/doorkeeper/oauth/base_request.rb +11 -19
- data/lib/doorkeeper/oauth/client/credentials.rb +2 -4
- data/lib/doorkeeper/oauth/client.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +26 -8
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +3 -2
- data/lib/doorkeeper/oauth/client_credentials/validator.rb +4 -2
- data/lib/doorkeeper/oauth/client_credentials_request.rb +8 -7
- data/lib/doorkeeper/oauth/code_request.rb +3 -3
- data/lib/doorkeeper/oauth/code_response.rb +6 -2
- data/lib/doorkeeper/oauth/error_response.rb +2 -4
- data/lib/doorkeeper/oauth/helpers/scope_checker.rb +1 -5
- data/lib/doorkeeper/oauth/hooks/context.rb +21 -0
- data/lib/doorkeeper/oauth/invalid_token_response.rb +2 -2
- data/lib/doorkeeper/oauth/password_access_token_request.rb +4 -6
- data/lib/doorkeeper/oauth/pre_authorization.rb +36 -30
- data/lib/doorkeeper/oauth/refresh_token_request.rb +18 -22
- data/lib/doorkeeper/oauth/token.rb +5 -6
- data/lib/doorkeeper/oauth/token_introspection.rb +4 -8
- data/lib/doorkeeper/oauth/token_request.rb +3 -3
- data/lib/doorkeeper/oauth/token_response.rb +1 -1
- data/lib/doorkeeper/orm/active_record/mixins/access_grant.rb +8 -3
- data/lib/doorkeeper/orm/active_record/mixins/access_token.rb +7 -3
- data/lib/doorkeeper/orm/active_record.rb +10 -2
- data/lib/doorkeeper/rails/routes/abstract_router.rb +35 -0
- data/lib/doorkeeper/rails/routes/mapper.rb +2 -2
- data/lib/doorkeeper/rails/routes/registry.rb +45 -0
- data/lib/doorkeeper/rails/routes.rb +13 -17
- data/lib/doorkeeper/request/refresh_token.rb +2 -1
- data/lib/doorkeeper/request/strategy.rb +2 -2
- data/lib/doorkeeper/server.rb +4 -4
- data/lib/doorkeeper/stale_records_cleaner.rb +4 -4
- data/lib/doorkeeper/version.rb +2 -2
- data/lib/doorkeeper.rb +106 -79
- data/lib/generators/doorkeeper/confidential_applications_generator.rb +1 -1
- data/lib/generators/doorkeeper/enable_polymorphic_resource_owner_generator.rb +39 -0
- data/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb.erb +2 -0
- data/lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb.erb +2 -0
- data/lib/generators/doorkeeper/templates/enable_pkce_migration.rb.erb +2 -0
- data/lib/generators/doorkeeper/templates/enable_polymorphic_resource_owner_migration.rb.erb +17 -0
- data/lib/generators/doorkeeper/templates/initializer.rb +39 -3
- data/lib/generators/doorkeeper/templates/migration.rb.erb +14 -5
- metadata +13 -296
- data/Appraisals +0 -40
- data/CODE_OF_CONDUCT.md +0 -46
- data/CONTRIBUTING.md +0 -49
- data/Dangerfile +0 -67
- data/Dockerfile +0 -29
- data/Gemfile +0 -25
- data/NEWS.md +0 -1
- data/RELEASING.md +0 -11
- data/Rakefile +0 -28
- data/SECURITY.md +0 -15
- data/UPGRADE.md +0 -2
- data/bin/console +0 -16
- data/doorkeeper.gemspec +0 -42
- data/gemfiles/rails_5_0.gemfile +0 -18
- data/gemfiles/rails_5_1.gemfile +0 -18
- data/gemfiles/rails_5_2.gemfile +0 -18
- data/gemfiles/rails_6_0.gemfile +0 -18
- data/gemfiles/rails_master.gemfile +0 -18
- data/spec/controllers/application_metal_controller_spec.rb +0 -64
- data/spec/controllers/applications_controller_spec.rb +0 -274
- data/spec/controllers/authorizations_controller_spec.rb +0 -608
- data/spec/controllers/protected_resources_controller_spec.rb +0 -361
- data/spec/controllers/token_info_controller_spec.rb +0 -50
- data/spec/controllers/tokens_controller_spec.rb +0 -498
- data/spec/dummy/Rakefile +0 -9
- data/spec/dummy/app/assets/config/manifest.js +0 -2
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/controllers/custom_authorizations_controller.rb +0 -9
- data/spec/dummy/app/controllers/full_protected_resources_controller.rb +0 -14
- data/spec/dummy/app/controllers/home_controller.rb +0 -18
- data/spec/dummy/app/controllers/metal_controller.rb +0 -13
- data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +0 -13
- data/spec/dummy/app/helpers/application_helper.rb +0 -7
- data/spec/dummy/app/models/user.rb +0 -7
- data/spec/dummy/app/views/home/index.html.erb +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/config/application.rb +0 -49
- data/spec/dummy/config/boot.rb +0 -7
- data/spec/dummy/config/database.yml +0 -15
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -31
- data/spec/dummy/config/environments/production.rb +0 -64
- data/spec/dummy/config/environments/test.rb +0 -45
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -9
- data/spec/dummy/config/initializers/doorkeeper.rb +0 -166
- data/spec/dummy/config/initializers/secret_token.rb +0 -10
- data/spec/dummy/config/initializers/session_store.rb +0 -10
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -16
- data/spec/dummy/config/locales/doorkeeper.en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -13
- data/spec/dummy/config.ru +0 -6
- data/spec/dummy/db/migrate/20111122132257_create_users.rb +0 -11
- data/spec/dummy/db/migrate/20120312140401_add_password_to_users.rb +0 -7
- data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +0 -69
- data/spec/dummy/db/migrate/20151223200000_add_owner_to_application.rb +0 -9
- data/spec/dummy/db/migrate/20160320211015_add_previous_refresh_token_to_access_tokens.rb +0 -13
- data/spec/dummy/db/migrate/20170822064514_enable_pkce.rb +0 -8
- data/spec/dummy/db/migrate/20180210183654_add_confidential_to_applications.rb +0 -13
- data/spec/dummy/db/schema.rb +0 -68
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -26
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -9
- data/spec/factories.rb +0 -30
- data/spec/generators/application_owner_generator_spec.rb +0 -28
- data/spec/generators/confidential_applications_generator_spec.rb +0 -29
- data/spec/generators/install_generator_spec.rb +0 -36
- data/spec/generators/migration_generator_spec.rb +0 -28
- data/spec/generators/pkce_generator_spec.rb +0 -28
- data/spec/generators/previous_refresh_token_generator_spec.rb +0 -44
- data/spec/generators/templates/routes.rb +0 -4
- data/spec/generators/views_generator_spec.rb +0 -29
- data/spec/grape/grape_integration_spec.rb +0 -137
- data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +0 -26
- data/spec/lib/config_spec.rb +0 -809
- data/spec/lib/doorkeeper_spec.rb +0 -27
- data/spec/lib/models/expirable_spec.rb +0 -61
- data/spec/lib/models/reusable_spec.rb +0 -40
- data/spec/lib/models/revocable_spec.rb +0 -59
- data/spec/lib/models/scopes_spec.rb +0 -53
- data/spec/lib/models/secret_storable_spec.rb +0 -135
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +0 -39
- data/spec/lib/oauth/authorization_code_request_spec.rb +0 -170
- data/spec/lib/oauth/base_request_spec.rb +0 -224
- data/spec/lib/oauth/base_response_spec.rb +0 -45
- data/spec/lib/oauth/client/credentials_spec.rb +0 -90
- data/spec/lib/oauth/client_credentials/creator_spec.rb +0 -134
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +0 -112
- data/spec/lib/oauth/client_credentials/validation_spec.rb +0 -59
- data/spec/lib/oauth/client_credentials_integration_spec.rb +0 -27
- data/spec/lib/oauth/client_credentials_request_spec.rb +0 -107
- data/spec/lib/oauth/client_spec.rb +0 -38
- data/spec/lib/oauth/code_request_spec.rb +0 -46
- data/spec/lib/oauth/code_response_spec.rb +0 -32
- data/spec/lib/oauth/error_response_spec.rb +0 -64
- data/spec/lib/oauth/error_spec.rb +0 -21
- data/spec/lib/oauth/forbidden_token_response_spec.rb +0 -20
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +0 -110
- data/spec/lib/oauth/helpers/unique_token_spec.rb +0 -21
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +0 -262
- data/spec/lib/oauth/invalid_request_response_spec.rb +0 -73
- data/spec/lib/oauth/invalid_token_response_spec.rb +0 -53
- data/spec/lib/oauth/password_access_token_request_spec.rb +0 -190
- data/spec/lib/oauth/pre_authorization_spec.rb +0 -223
- data/spec/lib/oauth/refresh_token_request_spec.rb +0 -177
- data/spec/lib/oauth/scopes_spec.rb +0 -146
- data/spec/lib/oauth/token_request_spec.rb +0 -157
- data/spec/lib/oauth/token_response_spec.rb +0 -84
- data/spec/lib/oauth/token_spec.rb +0 -156
- data/spec/lib/request/strategy_spec.rb +0 -54
- data/spec/lib/secret_storing/base_spec.rb +0 -60
- data/spec/lib/secret_storing/bcrypt_spec.rb +0 -49
- data/spec/lib/secret_storing/plain_spec.rb +0 -44
- data/spec/lib/secret_storing/sha256_hash_spec.rb +0 -48
- data/spec/lib/server_spec.rb +0 -49
- data/spec/lib/stale_records_cleaner_spec.rb +0 -89
- data/spec/models/doorkeeper/access_grant_spec.rb +0 -161
- data/spec/models/doorkeeper/access_token_spec.rb +0 -622
- data/spec/models/doorkeeper/application_spec.rb +0 -482
- data/spec/requests/applications/applications_request_spec.rb +0 -259
- data/spec/requests/applications/authorized_applications_spec.rb +0 -32
- data/spec/requests/endpoints/authorization_spec.rb +0 -91
- data/spec/requests/endpoints/token_spec.rb +0 -75
- data/spec/requests/flows/authorization_code_errors_spec.rb +0 -79
- data/spec/requests/flows/authorization_code_spec.rb +0 -525
- data/spec/requests/flows/client_credentials_spec.rb +0 -166
- data/spec/requests/flows/implicit_grant_errors_spec.rb +0 -46
- data/spec/requests/flows/implicit_grant_spec.rb +0 -91
- data/spec/requests/flows/password_spec.rb +0 -316
- data/spec/requests/flows/refresh_token_spec.rb +0 -233
- data/spec/requests/flows/revoke_token_spec.rb +0 -157
- data/spec/requests/flows/skip_authorization_spec.rb +0 -66
- data/spec/requests/protected_resources/metal_spec.rb +0 -16
- data/spec/requests/protected_resources/private_api_spec.rb +0 -83
- data/spec/routing/custom_controller_routes_spec.rb +0 -133
- data/spec/routing/default_routes_spec.rb +0 -41
- data/spec/routing/scoped_routes_spec.rb +0 -47
- data/spec/spec_helper.rb +0 -54
- data/spec/spec_helper_integration.rb +0 -4
- data/spec/support/dependencies/factory_bot.rb +0 -4
- data/spec/support/doorkeeper_rspec.rb +0 -22
- data/spec/support/helpers/access_token_request_helper.rb +0 -13
- data/spec/support/helpers/authorization_request_helper.rb +0 -43
- data/spec/support/helpers/config_helper.rb +0 -11
- data/spec/support/helpers/model_helper.rb +0 -78
- data/spec/support/helpers/request_spec_helper.rb +0 -110
- data/spec/support/helpers/url_helper.rb +0 -62
- data/spec/support/orm/active_record.rb +0 -5
- data/spec/support/shared/controllers_shared_context.rb +0 -133
- data/spec/support/shared/hashing_shared_context.rb +0 -36
- data/spec/support/shared/models_shared_examples.rb +0 -54
- data/spec/validators/redirect_uri_validator_spec.rb +0 -183
- data/spec/version/version_spec.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76b3a86e21584548c9b0c176512c844bee90ba9c447aaf09741abf54488093bb
|
4
|
+
data.tar.gz: ce7a4ffdf3b0aebaa69f703b70f0109276205c9ec0b2f1e2c7b3e88cb4746f8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7192f9711713f15d323e85aa3ad4274b314a55dcc89ba945de52dca5dbbad2e267dc3252da353cd4991fae365a1161fd91d06c0bfcaba767163b4c54eafca125
|
7
|
+
data.tar.gz: b5f324cfe8064b32254ca1c045bc24c54ab21a485bf3c6a9726bc995ab9dc24516872bf8ee314850b65f6ce3d879d0497e67416ea78c0f8f7566bdbfd48e024a
|
data/CHANGELOG.md
CHANGED
@@ -5,13 +5,17 @@ upgrade guides.
|
|
5
5
|
|
6
6
|
User-visible changes worth mentioning.
|
7
7
|
|
8
|
-
##
|
8
|
+
## master
|
9
9
|
|
10
|
-
- [#
|
10
|
+
- [#PR ID] Your PR description.
|
11
11
|
|
12
|
-
## 5.
|
12
|
+
## 5.4.0
|
13
13
|
|
14
|
-
- [#
|
14
|
+
- [#1404] Make `Doorkeeper::Application#read_attribute_for_serialization` public.
|
15
|
+
|
16
|
+
## 5.4.0.rc2
|
17
|
+
|
18
|
+
- [#1371] Add `#as_json` method and attributes serialization restriction for Application model.
|
15
19
|
Fixes information disclosure vulnerability (CVE-2020-10187).
|
16
20
|
|
17
21
|
**[IMPORTANT]** you need to re-implement `#as_json` method for Doorkeeper Application model
|
@@ -19,6 +23,54 @@ User-visible changes worth mentioning.
|
|
19
23
|
JSON response from /oauth/applications.json or /oauth/authorized_applications.json. This change
|
20
24
|
is a breaking change which restricts serialized attributes to a very small set of columns.
|
21
25
|
|
26
|
+
- [#1395] Fix `NameError: uninitialized constant Doorkeeper::AccessToken` for Rake tasks.
|
27
|
+
- [#1397] Add `as: :doorkeeper_application` on Doorkeeper application form in order to support
|
28
|
+
custom configured application model.
|
29
|
+
- [#1400] Correctly yield the application instance to `allow_grant_flow_for_client?` config
|
30
|
+
option (fixes #1398).
|
31
|
+
- [#1402] Handle trying authorization with client credentials.
|
32
|
+
|
33
|
+
## 5.4.0.rc1
|
34
|
+
- [#1366] Sets expiry of token generated using `refresh_token` to that of original token. (Fixes #1364)
|
35
|
+
- [#1354] Add `authorize_resource_owner_for_client` option to authorize the calling user to access an application.
|
36
|
+
- [#1355] Allow to enable polymorphic Resource Owner association for Access Token & Grant
|
37
|
+
models (`use_polymorphic_resource_owner` configuration option).
|
38
|
+
|
39
|
+
**[IMPORTANT]** Review your custom patches or extensions for Doorkeeper internals if you
|
40
|
+
have such - since now Doorkeeper passes Resource Owner instance to every objects and not
|
41
|
+
just it's ID. See PR description for details.
|
42
|
+
|
43
|
+
- [#1356] Remove duplicated scopes from Access Tokens and Grants on attribute assignment.
|
44
|
+
- [#1357] Fix `Doorkeeper::OAuth::PreAuthorization#as_json` method causing
|
45
|
+
`Stack level too deep` error with AMS (fix #1312).
|
46
|
+
- [#1358] Deprecate `active_record_options` configuration option.
|
47
|
+
- [#1359] Refactor Doorkeeper configuration options DSL to make it easy to reuse it
|
48
|
+
in external extensions.
|
49
|
+
- [#1360] Increase `matching_token_for` lookup size to 10 000 and make it configurable.
|
50
|
+
- [#1371] Fix controllers to use valid classes in case Doorkeeper has custom models configured.
|
51
|
+
- [#1370] Fix revocation response for invalid token and unauthorized requests to conform with RFC 7009 (fixes #1362).
|
52
|
+
|
53
|
+
**[IMPORTANT]** now fully according to RFC 7009 nobody can do a revocation request without `client_id`
|
54
|
+
(for public clients) and `client_secret` (for private clients). Please update your apps to include that
|
55
|
+
info in the revocation request payload.
|
56
|
+
|
57
|
+
- [#1373] Make Doorkeeper routes mapper reusable in extensions.
|
58
|
+
- [#1374] Revoke and issue client credentials token in a transaction with a row lock.
|
59
|
+
- [#1384] Add context object with auth/pre_auth and issued_token for authorization hooks.
|
60
|
+
- [#1387] Add `AccessToken#create_for` and use in `RefreshTokenRequest`.
|
61
|
+
- [#1392] Fix `enable_polymorphic_resource_owner` migration template to have proper index name.
|
62
|
+
- [#1393] Improve Applications #show page with more informative data on client secret and scopes.
|
63
|
+
- [#1394] Use Ruby `autoload` feature to load Doorkeeper files.
|
64
|
+
|
65
|
+
## 5.3.3
|
66
|
+
|
67
|
+
- [#1404] Backport: Make `Doorkeeper::Application#read_attribute_for_serialization` public.
|
68
|
+
|
69
|
+
## 5.3.2
|
70
|
+
|
71
|
+
- [#1371] Backport: add `#as_json` method and attributes serialization restriction for Application model.
|
72
|
+
Fixes information disclosure vulnerability (CVE-2020-10187).
|
73
|
+
|
22
74
|
## 5.3.1
|
23
75
|
|
24
76
|
- [#1360] Backport: Increase `matching_token_for` batch lookup size to 10 000 and make it configurable.
|
@@ -37,6 +89,15 @@ User-visible changes worth mentioning.
|
|
37
89
|
If you were relying on access tokens being revoked once the same client
|
38
90
|
requested a new access token, reenable it with `revoke_previous_client_credentials_token` in Doorkeeper
|
39
91
|
initialization file.
|
92
|
+
|
93
|
+
## 5.2.6
|
94
|
+
|
95
|
+
- [#1404] Backport: Make `Doorkeeper::Application#read_attribute_for_serialization` public.
|
96
|
+
|
97
|
+
## 5.2.5
|
98
|
+
|
99
|
+
- [#1371] Backport: add `#as_json` method and attributes serialization restriction for Application model.
|
100
|
+
Fixes information disclosure vulnerability (CVE-2020-10187).
|
40
101
|
|
41
102
|
## 5.2.4
|
42
103
|
|
@@ -70,6 +131,9 @@ User-visible changes worth mentioning.
|
|
70
131
|
- [#1298] Slice strong params so doesn't error with Rails forms.
|
71
132
|
- [#1300] Limiting access to attributes of pre_authorization.
|
72
133
|
- [#1296] Adding client_id to strong parameters.
|
134
|
+
|
135
|
+
**[IMPORTANT]** `Doorkeeper::Server#client_via_uid` was removed.
|
136
|
+
|
73
137
|
- [#1293] Move ar specific redirect uri validator to ar orm directory.
|
74
138
|
- [#1288] Allow to pass attributes to the `Doorkeeper::OAuth::PreAuthorization#as_json` method to customize
|
75
139
|
the PreAuthorization response.
|
@@ -102,6 +166,15 @@ User-visible changes worth mentioning.
|
|
102
166
|
- [#1248] Return the unhashed Application Secret in the JSON response after creating new application even when `hash_application_secrets` is used.
|
103
167
|
- [#1238] Better support for native app with support for custom scheme and localhost redirection.
|
104
168
|
|
169
|
+
## 5.1.2
|
170
|
+
|
171
|
+
- [#1404] Backport: Make `Doorkeeper::Application#read_attribute_for_serialization` public.
|
172
|
+
|
173
|
+
## 5.1.1
|
174
|
+
|
175
|
+
- [#1371] Backport: add `#as_json` method and attributes serialization restriction for Application model.
|
176
|
+
Fixes information disclosure vulnerability (CVE-2020-10187).
|
177
|
+
|
105
178
|
## 5.1.0
|
106
179
|
|
107
180
|
- [#1243] Add nil check operator in token checking at token introspection.
|
@@ -163,6 +236,11 @@ User-visible changes worth mentioning.
|
|
163
236
|
- [#1164] Fix error when `root_path` is not defined.
|
164
237
|
- [#1162] Fix `enforce_content_type` for requests without body.
|
165
238
|
|
239
|
+
## 5.0.3
|
240
|
+
|
241
|
+
- [#1371] Backport: add `#as_json` method and attributes serialization restriction for Application model.
|
242
|
+
Fixes information disclosure vulnerability (CVE-2020-10187).
|
243
|
+
|
166
244
|
## 5.0.2
|
167
245
|
|
168
246
|
- [#1158] Fix initializer template: change `handle_auth_errors` option
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
[![Coverage Status](https://coveralls.io/repos/github/doorkeeper-gem/doorkeeper/badge.svg?branch=master)](https://coveralls.io/github/doorkeeper-gem/doorkeeper?branch=master)
|
7
7
|
[![Security](https://hakiri.io/github/doorkeeper-gem/doorkeeper/master.svg)](https://hakiri.io/github/doorkeeper-gem/doorkeeper/master)
|
8
8
|
[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
|
9
|
-
[![GuardRails badge](https://badges.
|
9
|
+
[![GuardRails badge](https://badges.guardrails.io/doorkeeper-gem/doorkeeper.svg?token=66768ce8f6995814df81f65a2cff40f739f688492704f973e62809e15599bb62)](https://dashboard.guardrails.io/default/gh/doorkeeper-gem/doorkeeper)
|
10
10
|
[![Dependabot](https://img.shields.io/badge/dependabot-enabled-success.svg)](https://dependabot.com)
|
11
11
|
|
12
12
|
Doorkeeper is a gem (Rails engine) that makes it easy to introduce OAuth 2 provider
|
@@ -113,7 +113,7 @@ These applications show how Doorkeeper works and how to integrate with it. Start
|
|
113
113
|
|
114
114
|
| Application | Link |
|
115
115
|
| :--- | :--- |
|
116
|
-
|
|
116
|
+
| OAuth2 Server with Doorkeeper | [doorkeeper-gem/doorkeeper-provider-app](https://github.com/doorkeeper-gem/doorkeeper-provider-app) |
|
117
117
|
| Sinatra Client connected to Provider App | [doorkeeper-gem/doorkeeper-sinatra-client](https://github.com/doorkeeper-gem/doorkeeper-sinatra-client) |
|
118
118
|
| Devise + Omniauth Client | [doorkeeper-gem/doorkeeper-devise-client](https://github.com/doorkeeper-gem/doorkeeper-devise-client) |
|
119
119
|
|
@@ -160,6 +160,9 @@ tests with a specific Rails version:
|
|
160
160
|
BUNDLE_GEMFILE=gemfiles/rails_6_0.gemfile bundle exec rake
|
161
161
|
```
|
162
162
|
|
163
|
+
You can also experiment with the changes using `bin/console`. It uses in-memory SQLite database and default
|
164
|
+
Doorkeeper config, but you can reestablish connection or reconfigure the gem if you need.
|
165
|
+
|
163
166
|
## Contributing
|
164
167
|
|
165
168
|
Want to contribute and don't know where to start? Check out [features we're
|
@@ -168,8 +171,7 @@ create [example
|
|
168
171
|
apps](https://github.com/doorkeeper-gem/doorkeeper/wiki/Example-Applications),
|
169
172
|
integrate the gem with your app and let us know!
|
170
173
|
|
171
|
-
Also, check out our [contributing guidelines
|
172
|
-
page](https://github.com/doorkeeper-gem/doorkeeper/wiki/Contributing).
|
174
|
+
Also, check out our [contributing guidelines page](CONTRIBUTING.md).
|
173
175
|
|
174
176
|
## Contributors
|
175
177
|
|
@@ -8,7 +8,7 @@ module Doorkeeper
|
|
8
8
|
before_action :set_application, only: %i[show edit update destroy]
|
9
9
|
|
10
10
|
def index
|
11
|
-
@applications =
|
11
|
+
@applications = Doorkeeper.config.application_model.ordered_by(:created_at)
|
12
12
|
|
13
13
|
respond_to do |format|
|
14
14
|
format.html
|
@@ -24,11 +24,11 @@ module Doorkeeper
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def new
|
27
|
-
@application =
|
27
|
+
@application = Doorkeeper.config.application_model.new
|
28
28
|
end
|
29
29
|
|
30
30
|
def create
|
31
|
-
@application =
|
31
|
+
@application = Doorkeeper.config.application_model.new(application_params)
|
32
32
|
|
33
33
|
if @application.save
|
34
34
|
flash[:notice] = I18n.t(:notice, scope: %i[doorkeeper flash applications create])
|
@@ -84,7 +84,7 @@ module Doorkeeper
|
|
84
84
|
private
|
85
85
|
|
86
86
|
def set_application
|
87
|
-
@application =
|
87
|
+
@application = Doorkeeper.config.application_model.find(params[:id])
|
88
88
|
end
|
89
89
|
|
90
90
|
def application_params
|
@@ -42,9 +42,9 @@ module Doorkeeper
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def matching_token?
|
45
|
-
|
45
|
+
Doorkeeper.config.access_token_model.matching_token_for(
|
46
46
|
pre_auth.client,
|
47
|
-
current_resource_owner
|
47
|
+
current_resource_owner,
|
48
48
|
pre_auth.scopes,
|
49
49
|
)
|
50
50
|
end
|
@@ -65,7 +65,11 @@ module Doorkeeper
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def pre_auth
|
68
|
-
@pre_auth ||= OAuth::PreAuthorization.new(
|
68
|
+
@pre_auth ||= OAuth::PreAuthorization.new(
|
69
|
+
Doorkeeper.configuration,
|
70
|
+
pre_auth_params,
|
71
|
+
current_resource_owner,
|
72
|
+
)
|
69
73
|
end
|
70
74
|
|
71
75
|
def pre_auth_params
|
@@ -73,8 +77,14 @@ module Doorkeeper
|
|
73
77
|
end
|
74
78
|
|
75
79
|
def pre_auth_param_fields
|
76
|
-
%i[
|
77
|
-
|
80
|
+
%i[
|
81
|
+
client_id
|
82
|
+
code_challenge
|
83
|
+
code_challenge_method
|
84
|
+
response_type
|
85
|
+
redirect_uri
|
86
|
+
scope state
|
87
|
+
]
|
78
88
|
end
|
79
89
|
|
80
90
|
def authorization
|
@@ -82,26 +92,35 @@ module Doorkeeper
|
|
82
92
|
end
|
83
93
|
|
84
94
|
def strategy
|
85
|
-
@strategy ||= server.authorization_request
|
95
|
+
@strategy ||= server.authorization_request(pre_auth.response_type)
|
86
96
|
end
|
87
97
|
|
88
98
|
def authorize_response
|
89
99
|
@authorize_response ||= begin
|
90
100
|
return pre_auth.error_response unless pre_auth.authorizable?
|
91
101
|
|
92
|
-
|
102
|
+
context = build_context(pre_auth: pre_auth)
|
103
|
+
before_successful_authorization(context)
|
104
|
+
|
93
105
|
auth = strategy.authorize
|
94
|
-
|
106
|
+
|
107
|
+
context = build_context(auth: auth)
|
108
|
+
after_successful_authorization(context)
|
109
|
+
|
95
110
|
auth
|
96
111
|
end
|
97
112
|
end
|
98
113
|
|
99
|
-
def
|
100
|
-
Doorkeeper.
|
114
|
+
def build_context(**attributes)
|
115
|
+
Doorkeeper::OAuth::Hooks::Context.new(**attributes)
|
116
|
+
end
|
117
|
+
|
118
|
+
def before_successful_authorization(context = nil)
|
119
|
+
Doorkeeper.config.before_successful_authorization.call(self, context)
|
101
120
|
end
|
102
121
|
|
103
|
-
def
|
104
|
-
Doorkeeper.
|
122
|
+
def after_successful_authorization(context)
|
123
|
+
Doorkeeper.config.after_successful_authorization.call(self, context)
|
105
124
|
end
|
106
125
|
end
|
107
126
|
end
|
@@ -5,7 +5,7 @@ module Doorkeeper
|
|
5
5
|
before_action :authenticate_resource_owner!
|
6
6
|
|
7
7
|
def index
|
8
|
-
@applications =
|
8
|
+
@applications = Doorkeeper.config.application_model.authorized_for(current_resource_owner)
|
9
9
|
|
10
10
|
respond_to do |format|
|
11
11
|
format.html
|
@@ -14,7 +14,7 @@ module Doorkeeper
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def destroy
|
17
|
-
|
17
|
+
Doorkeeper.config.application_model.revoke_tokens_and_grants_for(
|
18
18
|
params[:id],
|
19
19
|
current_resource_owner,
|
20
20
|
)
|
@@ -12,14 +12,41 @@ module Doorkeeper
|
|
12
12
|
|
13
13
|
# OAuth 2.0 Token Revocation - http://tools.ietf.org/html/rfc7009
|
14
14
|
def revoke
|
15
|
-
#
|
16
|
-
# and checks its ownership of the provided token.
|
15
|
+
# @see 2.1. Revocation Request
|
17
16
|
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
17
|
+
# The client constructs the request by including the following
|
18
|
+
# parameters using the "application/x-www-form-urlencoded" format in
|
19
|
+
# the HTTP request entity-body:
|
20
|
+
# token REQUIRED.
|
21
|
+
# token_type_hint OPTIONAL.
|
22
|
+
#
|
23
|
+
# The client also includes its authentication credentials as described
|
24
|
+
# in Section 2.3. of [RFC6749].
|
25
|
+
#
|
26
|
+
# The authorization server first validates the client credentials (in
|
27
|
+
# case of a confidential client) and then verifies whether the token
|
28
|
+
# was issued to the client making the revocation request.
|
29
|
+
unless server.client
|
30
|
+
# If this validation [client credentials / token ownership] fails, the request is
|
31
|
+
# refused and the client is informed of the error by the authorization server as
|
32
|
+
# described below.
|
33
|
+
#
|
34
|
+
# @see 2.2.1. Error Response
|
35
|
+
#
|
36
|
+
# The error presentation conforms to the definition in Section 5.2 of [RFC6749].
|
37
|
+
render json: revocation_error_response, status: :forbidden
|
38
|
+
return
|
39
|
+
end
|
21
40
|
|
22
|
-
if
|
41
|
+
# The authorization server responds with HTTP status code 200 if the client
|
42
|
+
# submitted an invalid token or the token has been revoked successfully.
|
43
|
+
if token.blank?
|
44
|
+
render json: {}, status: 200
|
45
|
+
# The authorization server validates [...] and whether the token
|
46
|
+
# was issued to the client making the revocation request. If this
|
47
|
+
# validation fails, the request is refused and the client is informed
|
48
|
+
# of the error by the authorization server as described below.
|
49
|
+
elsif authorized?
|
23
50
|
revoke_token
|
24
51
|
render json: {}, status: 200
|
25
52
|
else
|
@@ -42,8 +69,12 @@ module Doorkeeper
|
|
42
69
|
private
|
43
70
|
|
44
71
|
# OAuth 2.0 Section 2.1 defines two client types, "public" & "confidential".
|
45
|
-
#
|
46
|
-
#
|
72
|
+
# A malicious client may attempt to guess valid tokens on this endpoint
|
73
|
+
# by making revocation requests against potential token strings.
|
74
|
+
# According to this specification, a client's request must contain a
|
75
|
+
# valid client_id, in the case of a public client, or valid client
|
76
|
+
# credentials, in the case of a confidential client. The token being
|
77
|
+
# revoked must also belong to the requesting client.
|
47
78
|
#
|
48
79
|
# Once a confidential client is authenticated, it must be authorized to
|
49
80
|
# revoke the provided access or refresh token. This ensures one client
|
@@ -58,15 +89,13 @@ module Doorkeeper
|
|
58
89
|
# https://tools.ietf.org/html/rfc6749#section-2.1
|
59
90
|
# https://tools.ietf.org/html/rfc7009
|
60
91
|
def authorized?
|
61
|
-
|
62
|
-
|
63
|
-
# Client is confidential, therefore client authentication & authorization
|
64
|
-
# is required
|
92
|
+
# Token belongs to specific client, so we need to check if
|
93
|
+
# authenticated client could access it.
|
65
94
|
if token.application_id? && token.application.confidential?
|
66
95
|
# We authorize client by checking token's application
|
67
96
|
server.client && server.client.application == token.application
|
68
97
|
else
|
69
|
-
#
|
98
|
+
# Token was issued without client, authorization unnecessary
|
70
99
|
true
|
71
100
|
end
|
72
101
|
end
|
@@ -78,9 +107,12 @@ module Doorkeeper
|
|
78
107
|
token.revoke if token&.accessible?
|
79
108
|
end
|
80
109
|
|
110
|
+
# Doorkeeper does not use the token_type_hint logic described in the
|
111
|
+
# RFC 7009 due to the refresh token implementation that is a field in
|
112
|
+
# the access token model.
|
81
113
|
def token
|
82
|
-
@token ||=
|
83
|
-
|
114
|
+
@token ||= Doorkeeper.config.access_token_model.by_token(params["token"]) ||
|
115
|
+
Doorkeeper.config.access_token_model.by_refresh_token(params["token"])
|
84
116
|
end
|
85
117
|
|
86
118
|
def strategy
|
@@ -91,17 +123,22 @@ module Doorkeeper
|
|
91
123
|
@authorize_response ||= begin
|
92
124
|
before_successful_authorization
|
93
125
|
auth = strategy.authorize
|
94
|
-
|
126
|
+
context = build_context(auth: auth)
|
127
|
+
after_successful_authorization(context) unless auth.is_a?(Doorkeeper::OAuth::ErrorResponse)
|
95
128
|
auth
|
96
129
|
end
|
97
130
|
end
|
98
131
|
|
99
|
-
def
|
100
|
-
Doorkeeper.
|
132
|
+
def build_context(**attributes)
|
133
|
+
Doorkeeper::OAuth::Hooks::Context.new(**attributes)
|
134
|
+
end
|
135
|
+
|
136
|
+
def before_successful_authorization(context = nil)
|
137
|
+
Doorkeeper.config.before_successful_authorization.call(self, context)
|
101
138
|
end
|
102
139
|
|
103
|
-
def
|
104
|
-
Doorkeeper.
|
140
|
+
def after_successful_authorization(context)
|
141
|
+
Doorkeeper.config.after_successful_authorization.call(self, context)
|
105
142
|
end
|
106
143
|
|
107
144
|
def revocation_error_response
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_for application, url: doorkeeper_submit_path(application), html: { role: 'form' } do |f| %>
|
1
|
+
<%= form_for application, url: doorkeeper_submit_path(application), as: :doorkeeper_application, html: { role: 'form' } do |f| %>
|
2
2
|
<% if application.errors.any? %>
|
3
3
|
<div class="alert alert-danger" data-alert><p><%= t('doorkeeper.applications.form.error') %></p></div>
|
4
4
|
<% end %>
|
@@ -8,10 +8,27 @@
|
|
8
8
|
<p><code class="bg-light" id="application_id"><%= @application.uid %></code></p>
|
9
9
|
|
10
10
|
<h4><%= t('.secret') %>:</h4>
|
11
|
-
<p
|
11
|
+
<p>
|
12
|
+
<code class="bg-light" id="secret">
|
13
|
+
<% secret = flash[:application_secret].presence || @application.plaintext_secret %>
|
14
|
+
<% if secret.blank? && Doorkeeper.config.application_secret_hashed? %>
|
15
|
+
<span class="bg-light font-italic text-uppercase text-muted"><%= t('.secret_hashed') %></span>
|
16
|
+
<% else %>
|
17
|
+
<%= secret %>
|
18
|
+
<% end %>
|
19
|
+
</code>
|
20
|
+
</p>
|
12
21
|
|
13
22
|
<h4><%= t('.scopes') %>:</h4>
|
14
|
-
<p
|
23
|
+
<p>
|
24
|
+
<code class="bg-light" id="scopes">
|
25
|
+
<% if @application.scopes.present? %>
|
26
|
+
<%= @application.scopes %>
|
27
|
+
<% else %>
|
28
|
+
<span class="bg-light font-italic text-uppercase text-muted"><%= t('.not_defined') %></span>
|
29
|
+
<% end %>
|
30
|
+
</code>
|
31
|
+
</p>
|
15
32
|
|
16
33
|
<h4><%= t('.confidential') %>:</h4>
|
17
34
|
<p><code class="bg-light" id="confidential"><%= @application.confidential? %></code></p>
|
data/config/locales/en.yml
CHANGED
@@ -51,12 +51,14 @@ en:
|
|
51
51
|
title: 'New Application'
|
52
52
|
show:
|
53
53
|
title: 'Application: %{name}'
|
54
|
-
application_id: '
|
54
|
+
application_id: 'UID'
|
55
55
|
secret: 'Secret'
|
56
|
+
secret_hashed: 'Secret hashed'
|
56
57
|
scopes: 'Scopes'
|
57
58
|
confidential: 'Confidential'
|
58
59
|
callback_urls: 'Callback urls'
|
59
60
|
actions: 'Actions'
|
61
|
+
not_defined: 'Not defined'
|
60
62
|
|
61
63
|
authorizations:
|
62
64
|
buttons:
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Doorkeeper
|
4
|
+
class Config
|
5
|
+
# Abstract base class for Doorkeeper and it's extensions configuration
|
6
|
+
# builder. Instantiates and validates gem configuration.
|
7
|
+
#
|
8
|
+
class AbstractBuilder
|
9
|
+
attr_reader :config
|
10
|
+
|
11
|
+
# @param [Class] config class
|
12
|
+
#
|
13
|
+
def initialize(config = Config.new, &block)
|
14
|
+
@config = config
|
15
|
+
instance_eval(&block)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Builds and validates configuration.
|
19
|
+
#
|
20
|
+
# @return [Doorkeeper::Config] config instance
|
21
|
+
#
|
22
|
+
def build
|
23
|
+
@config.validate! if @config.respond_to?(:validate!)
|
24
|
+
@config
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -36,22 +36,29 @@ module Doorkeeper
|
|
36
36
|
attribute = options[:as] || name
|
37
37
|
attribute_builder = options[:builder_class]
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
else
|
46
|
-
define_method name do |*args, &block|
|
47
|
-
value = if attribute_builder
|
48
|
-
attribute_builder.new(&block).build
|
49
|
-
else
|
50
|
-
block || args.first
|
51
|
-
end
|
39
|
+
builder_class.instance_eval do
|
40
|
+
if method_defined?(name)
|
41
|
+
Kernel.warn "[DOORKEEPER] Option #{name} already defined and will be overridden"
|
42
|
+
remove_method name
|
43
|
+
end
|
52
44
|
|
53
|
-
|
45
|
+
define_method name do |*args, &block|
|
46
|
+
if (deprecation_opts = options[:deprecated])
|
47
|
+
warning = "[DOORKEEPER] #{name} has been deprecated and will soon be removed"
|
48
|
+
if deprecation_opts.is_a?(Hash)
|
49
|
+
warning = "#{warning}\n#{deprecation_opts.fetch(:message)}"
|
50
|
+
end
|
51
|
+
|
52
|
+
Kernel.warn(warning)
|
54
53
|
end
|
54
|
+
|
55
|
+
value = if attribute_builder
|
56
|
+
attribute_builder.new(&block).build
|
57
|
+
else
|
58
|
+
block || args.first
|
59
|
+
end
|
60
|
+
|
61
|
+
@config.instance_variable_set(:"@#{attribute}", value)
|
55
62
|
end
|
56
63
|
end
|
57
64
|
|
@@ -65,6 +72,13 @@ module Doorkeeper
|
|
65
72
|
|
66
73
|
public attribute
|
67
74
|
end
|
75
|
+
|
76
|
+
def self.extended(base)
|
77
|
+
return if base.respond_to?(:builder_class)
|
78
|
+
|
79
|
+
raise Doorkeeper::MissingConfigurationBuilderClass, "Define `self.builder_class` method " \
|
80
|
+
"for #{base} that returns your custom Builder class to use options DSL!"
|
81
|
+
end
|
68
82
|
end
|
69
83
|
end
|
70
84
|
end
|