doorkeeper 5.3.2 → 5.5.0.rc1

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.

Files changed (231) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +106 -2
  3. data/README.md +6 -4
  4. data/app/controllers/doorkeeper/applications_controller.rb +4 -4
  5. data/app/controllers/doorkeeper/authorizations_controller.rb +32 -12
  6. data/app/controllers/doorkeeper/authorized_applications_controller.rb +2 -2
  7. data/app/controllers/doorkeeper/tokens_controller.rb +60 -20
  8. data/app/views/doorkeeper/applications/_form.html.erb +1 -1
  9. data/app/views/doorkeeper/applications/show.html.erb +19 -2
  10. data/config/locales/en.yml +3 -2
  11. data/lib/doorkeeper.rb +107 -79
  12. data/lib/doorkeeper/config.rb +140 -94
  13. data/lib/doorkeeper/config/abstract_builder.rb +28 -0
  14. data/lib/doorkeeper/config/option.rb +26 -14
  15. data/lib/doorkeeper/config/validations.rb +53 -0
  16. data/lib/doorkeeper/engine.rb +1 -1
  17. data/lib/doorkeeper/grant_flow.rb +43 -0
  18. data/lib/doorkeeper/grant_flow/fallback_flow.rb +15 -0
  19. data/lib/doorkeeper/grant_flow/flow.rb +34 -0
  20. data/lib/doorkeeper/grant_flow/registry.rb +50 -0
  21. data/lib/doorkeeper/grape/helpers.rb +1 -1
  22. data/lib/doorkeeper/helpers/controller.rb +6 -4
  23. data/lib/doorkeeper/models/access_grant_mixin.rb +20 -16
  24. data/lib/doorkeeper/models/access_token_mixin.rb +110 -47
  25. data/lib/doorkeeper/models/application_mixin.rb +5 -4
  26. data/lib/doorkeeper/models/concerns/resource_ownerable.rb +47 -0
  27. data/lib/doorkeeper/models/concerns/revocable.rb +1 -1
  28. data/lib/doorkeeper/models/concerns/scopes.rb +5 -1
  29. data/lib/doorkeeper/models/concerns/secret_storable.rb +1 -3
  30. data/lib/doorkeeper/oauth/authorization/code.rb +15 -6
  31. data/lib/doorkeeper/oauth/authorization/context.rb +5 -5
  32. data/lib/doorkeeper/oauth/authorization/token.rb +14 -16
  33. data/lib/doorkeeper/oauth/authorization/uri_builder.rb +4 -4
  34. data/lib/doorkeeper/oauth/authorization_code_request.rb +17 -14
  35. data/lib/doorkeeper/oauth/base_request.rb +12 -20
  36. data/lib/doorkeeper/oauth/client.rb +1 -1
  37. data/lib/doorkeeper/oauth/client/credentials.rb +2 -4
  38. data/lib/doorkeeper/oauth/client_credentials/creator.rb +27 -8
  39. data/lib/doorkeeper/oauth/client_credentials/issuer.rb +4 -2
  40. data/lib/doorkeeper/oauth/client_credentials/validator.rb +4 -2
  41. data/lib/doorkeeper/oauth/client_credentials_request.rb +8 -7
  42. data/lib/doorkeeper/oauth/code_request.rb +3 -3
  43. data/lib/doorkeeper/oauth/code_response.rb +28 -14
  44. data/lib/doorkeeper/oauth/error_response.rb +6 -7
  45. data/lib/doorkeeper/oauth/helpers/scope_checker.rb +2 -8
  46. data/lib/doorkeeper/oauth/hooks/context.rb +21 -0
  47. data/lib/doorkeeper/oauth/invalid_token_response.rb +2 -2
  48. data/lib/doorkeeper/oauth/password_access_token_request.rb +24 -7
  49. data/lib/doorkeeper/oauth/pre_authorization.rb +41 -31
  50. data/lib/doorkeeper/oauth/refresh_token_request.rb +31 -22
  51. data/lib/doorkeeper/oauth/token.rb +5 -6
  52. data/lib/doorkeeper/oauth/token_introspection.rb +4 -8
  53. data/lib/doorkeeper/oauth/token_request.rb +3 -3
  54. data/lib/doorkeeper/oauth/token_response.rb +1 -1
  55. data/lib/doorkeeper/orm/active_record.rb +10 -2
  56. data/lib/doorkeeper/orm/active_record/mixins/access_grant.rb +8 -3
  57. data/lib/doorkeeper/orm/active_record/mixins/access_token.rb +7 -3
  58. data/lib/doorkeeper/orm/active_record/mixins/application.rb +20 -16
  59. data/lib/doorkeeper/rails/routes.rb +14 -18
  60. data/lib/doorkeeper/rails/routes/abstract_router.rb +35 -0
  61. data/lib/doorkeeper/rails/routes/mapper.rb +2 -2
  62. data/lib/doorkeeper/rails/routes/registry.rb +45 -0
  63. data/lib/doorkeeper/request.rb +49 -12
  64. data/lib/doorkeeper/request/refresh_token.rb +2 -1
  65. data/lib/doorkeeper/request/strategy.rb +2 -2
  66. data/lib/doorkeeper/server.rb +4 -4
  67. data/lib/doorkeeper/stale_records_cleaner.rb +4 -4
  68. data/lib/doorkeeper/version.rb +3 -3
  69. data/lib/generators/doorkeeper/confidential_applications_generator.rb +1 -1
  70. data/lib/generators/doorkeeper/enable_polymorphic_resource_owner_generator.rb +39 -0
  71. data/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb.erb +2 -0
  72. data/lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb.erb +2 -0
  73. data/lib/generators/doorkeeper/templates/enable_pkce_migration.rb.erb +2 -0
  74. data/lib/generators/doorkeeper/templates/enable_polymorphic_resource_owner_migration.rb.erb +17 -0
  75. data/lib/generators/doorkeeper/templates/initializer.rb +48 -10
  76. data/lib/generators/doorkeeper/templates/migration.rb.erb +14 -5
  77. metadata +21 -299
  78. data/Appraisals +0 -40
  79. data/CODE_OF_CONDUCT.md +0 -46
  80. data/CONTRIBUTING.md +0 -49
  81. data/Dangerfile +0 -67
  82. data/Dockerfile +0 -29
  83. data/Gemfile +0 -25
  84. data/NEWS.md +0 -1
  85. data/RELEASING.md +0 -11
  86. data/Rakefile +0 -28
  87. data/SECURITY.md +0 -15
  88. data/UPGRADE.md +0 -2
  89. data/bin/console +0 -16
  90. data/doorkeeper.gemspec +0 -42
  91. data/gemfiles/rails_5_0.gemfile +0 -18
  92. data/gemfiles/rails_5_1.gemfile +0 -18
  93. data/gemfiles/rails_5_2.gemfile +0 -18
  94. data/gemfiles/rails_6_0.gemfile +0 -18
  95. data/gemfiles/rails_master.gemfile +0 -18
  96. data/spec/controllers/application_metal_controller_spec.rb +0 -64
  97. data/spec/controllers/applications_controller_spec.rb +0 -274
  98. data/spec/controllers/authorizations_controller_spec.rb +0 -608
  99. data/spec/controllers/protected_resources_controller_spec.rb +0 -361
  100. data/spec/controllers/token_info_controller_spec.rb +0 -50
  101. data/spec/controllers/tokens_controller_spec.rb +0 -498
  102. data/spec/dummy/Rakefile +0 -9
  103. data/spec/dummy/app/assets/config/manifest.js +0 -2
  104. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  105. data/spec/dummy/app/controllers/custom_authorizations_controller.rb +0 -9
  106. data/spec/dummy/app/controllers/full_protected_resources_controller.rb +0 -14
  107. data/spec/dummy/app/controllers/home_controller.rb +0 -18
  108. data/spec/dummy/app/controllers/metal_controller.rb +0 -13
  109. data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +0 -13
  110. data/spec/dummy/app/helpers/application_helper.rb +0 -7
  111. data/spec/dummy/app/models/user.rb +0 -7
  112. data/spec/dummy/app/views/home/index.html.erb +0 -0
  113. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  114. data/spec/dummy/config.ru +0 -6
  115. data/spec/dummy/config/application.rb +0 -49
  116. data/spec/dummy/config/boot.rb +0 -7
  117. data/spec/dummy/config/database.yml +0 -15
  118. data/spec/dummy/config/environment.rb +0 -5
  119. data/spec/dummy/config/environments/development.rb +0 -31
  120. data/spec/dummy/config/environments/production.rb +0 -64
  121. data/spec/dummy/config/environments/test.rb +0 -45
  122. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -9
  123. data/spec/dummy/config/initializers/doorkeeper.rb +0 -166
  124. data/spec/dummy/config/initializers/secret_token.rb +0 -10
  125. data/spec/dummy/config/initializers/session_store.rb +0 -10
  126. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -16
  127. data/spec/dummy/config/locales/doorkeeper.en.yml +0 -5
  128. data/spec/dummy/config/routes.rb +0 -13
  129. data/spec/dummy/db/migrate/20111122132257_create_users.rb +0 -11
  130. data/spec/dummy/db/migrate/20120312140401_add_password_to_users.rb +0 -7
  131. data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +0 -69
  132. data/spec/dummy/db/migrate/20151223200000_add_owner_to_application.rb +0 -9
  133. data/spec/dummy/db/migrate/20160320211015_add_previous_refresh_token_to_access_tokens.rb +0 -13
  134. data/spec/dummy/db/migrate/20170822064514_enable_pkce.rb +0 -8
  135. data/spec/dummy/db/migrate/20180210183654_add_confidential_to_applications.rb +0 -13
  136. data/spec/dummy/db/schema.rb +0 -68
  137. data/spec/dummy/public/404.html +0 -26
  138. data/spec/dummy/public/422.html +0 -26
  139. data/spec/dummy/public/500.html +0 -26
  140. data/spec/dummy/public/favicon.ico +0 -0
  141. data/spec/dummy/script/rails +0 -9
  142. data/spec/factories.rb +0 -30
  143. data/spec/generators/application_owner_generator_spec.rb +0 -28
  144. data/spec/generators/confidential_applications_generator_spec.rb +0 -29
  145. data/spec/generators/install_generator_spec.rb +0 -36
  146. data/spec/generators/migration_generator_spec.rb +0 -28
  147. data/spec/generators/pkce_generator_spec.rb +0 -28
  148. data/spec/generators/previous_refresh_token_generator_spec.rb +0 -44
  149. data/spec/generators/templates/routes.rb +0 -4
  150. data/spec/generators/views_generator_spec.rb +0 -29
  151. data/spec/grape/grape_integration_spec.rb +0 -137
  152. data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +0 -26
  153. data/spec/lib/config_spec.rb +0 -809
  154. data/spec/lib/doorkeeper_spec.rb +0 -27
  155. data/spec/lib/models/expirable_spec.rb +0 -61
  156. data/spec/lib/models/reusable_spec.rb +0 -40
  157. data/spec/lib/models/revocable_spec.rb +0 -59
  158. data/spec/lib/models/scopes_spec.rb +0 -53
  159. data/spec/lib/models/secret_storable_spec.rb +0 -135
  160. data/spec/lib/oauth/authorization/uri_builder_spec.rb +0 -39
  161. data/spec/lib/oauth/authorization_code_request_spec.rb +0 -170
  162. data/spec/lib/oauth/base_request_spec.rb +0 -224
  163. data/spec/lib/oauth/base_response_spec.rb +0 -45
  164. data/spec/lib/oauth/client/credentials_spec.rb +0 -90
  165. data/spec/lib/oauth/client_credentials/creator_spec.rb +0 -134
  166. data/spec/lib/oauth/client_credentials/issuer_spec.rb +0 -112
  167. data/spec/lib/oauth/client_credentials/validation_spec.rb +0 -59
  168. data/spec/lib/oauth/client_credentials_integration_spec.rb +0 -27
  169. data/spec/lib/oauth/client_credentials_request_spec.rb +0 -107
  170. data/spec/lib/oauth/client_spec.rb +0 -38
  171. data/spec/lib/oauth/code_request_spec.rb +0 -46
  172. data/spec/lib/oauth/code_response_spec.rb +0 -32
  173. data/spec/lib/oauth/error_response_spec.rb +0 -64
  174. data/spec/lib/oauth/error_spec.rb +0 -21
  175. data/spec/lib/oauth/forbidden_token_response_spec.rb +0 -20
  176. data/spec/lib/oauth/helpers/scope_checker_spec.rb +0 -110
  177. data/spec/lib/oauth/helpers/unique_token_spec.rb +0 -21
  178. data/spec/lib/oauth/helpers/uri_checker_spec.rb +0 -262
  179. data/spec/lib/oauth/invalid_request_response_spec.rb +0 -73
  180. data/spec/lib/oauth/invalid_token_response_spec.rb +0 -53
  181. data/spec/lib/oauth/password_access_token_request_spec.rb +0 -190
  182. data/spec/lib/oauth/pre_authorization_spec.rb +0 -223
  183. data/spec/lib/oauth/refresh_token_request_spec.rb +0 -177
  184. data/spec/lib/oauth/scopes_spec.rb +0 -146
  185. data/spec/lib/oauth/token_request_spec.rb +0 -157
  186. data/spec/lib/oauth/token_response_spec.rb +0 -84
  187. data/spec/lib/oauth/token_spec.rb +0 -156
  188. data/spec/lib/request/strategy_spec.rb +0 -54
  189. data/spec/lib/secret_storing/base_spec.rb +0 -60
  190. data/spec/lib/secret_storing/bcrypt_spec.rb +0 -49
  191. data/spec/lib/secret_storing/plain_spec.rb +0 -44
  192. data/spec/lib/secret_storing/sha256_hash_spec.rb +0 -48
  193. data/spec/lib/server_spec.rb +0 -49
  194. data/spec/lib/stale_records_cleaner_spec.rb +0 -89
  195. data/spec/models/doorkeeper/access_grant_spec.rb +0 -161
  196. data/spec/models/doorkeeper/access_token_spec.rb +0 -622
  197. data/spec/models/doorkeeper/application_spec.rb +0 -482
  198. data/spec/requests/applications/applications_request_spec.rb +0 -259
  199. data/spec/requests/applications/authorized_applications_spec.rb +0 -32
  200. data/spec/requests/endpoints/authorization_spec.rb +0 -91
  201. data/spec/requests/endpoints/token_spec.rb +0 -75
  202. data/spec/requests/flows/authorization_code_errors_spec.rb +0 -79
  203. data/spec/requests/flows/authorization_code_spec.rb +0 -525
  204. data/spec/requests/flows/client_credentials_spec.rb +0 -166
  205. data/spec/requests/flows/implicit_grant_errors_spec.rb +0 -46
  206. data/spec/requests/flows/implicit_grant_spec.rb +0 -91
  207. data/spec/requests/flows/password_spec.rb +0 -316
  208. data/spec/requests/flows/refresh_token_spec.rb +0 -233
  209. data/spec/requests/flows/revoke_token_spec.rb +0 -157
  210. data/spec/requests/flows/skip_authorization_spec.rb +0 -66
  211. data/spec/requests/protected_resources/metal_spec.rb +0 -16
  212. data/spec/requests/protected_resources/private_api_spec.rb +0 -83
  213. data/spec/routing/custom_controller_routes_spec.rb +0 -133
  214. data/spec/routing/default_routes_spec.rb +0 -41
  215. data/spec/routing/scoped_routes_spec.rb +0 -47
  216. data/spec/spec_helper.rb +0 -54
  217. data/spec/spec_helper_integration.rb +0 -4
  218. data/spec/support/dependencies/factory_bot.rb +0 -4
  219. data/spec/support/doorkeeper_rspec.rb +0 -22
  220. data/spec/support/helpers/access_token_request_helper.rb +0 -13
  221. data/spec/support/helpers/authorization_request_helper.rb +0 -43
  222. data/spec/support/helpers/config_helper.rb +0 -11
  223. data/spec/support/helpers/model_helper.rb +0 -78
  224. data/spec/support/helpers/request_spec_helper.rb +0 -110
  225. data/spec/support/helpers/url_helper.rb +0 -62
  226. data/spec/support/orm/active_record.rb +0 -5
  227. data/spec/support/shared/controllers_shared_context.rb +0 -133
  228. data/spec/support/shared/hashing_shared_context.rb +0 -36
  229. data/spec/support/shared/models_shared_examples.rb +0 -54
  230. data/spec/validators/redirect_uri_validator_spec.rb +0 -183
  231. data/spec/version/version_spec.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a2e558c16d91012fda8543a405ee8e107ec3e100edc255ef9c0453e15fee34b
4
- data.tar.gz: 0e9ffe0268ccfb370ec23cd5c5b124e8febdec591cd0d5443974bd73942079f2
3
+ metadata.gz: 1099136de2b2fe0f0443f88bdbe2260ebed52efb2aab31d1d35bb7aa9f801acd
4
+ data.tar.gz: '09837820494b55d6bd26e2d997c203b221bc7951e74a6d1e2197122a86f0f1b2'
5
5
  SHA512:
6
- metadata.gz: 11b2350bfbe3e18b7500b9a159096dda35fc2307f66ab5ccec9e1266c18a4fc34e1ac9a8ffa763f713cd431dbb9a5fee7734bcd9d6576b41749101e3f149e969
7
- data.tar.gz: 7fdb1df4a142ac870a3a37838c4131a7514f81571319339c115754bf92ad3ed97c9e5a543008b94da6117e854104e418052bb634a5e5fcfb460063ecb83c6b5d
6
+ metadata.gz: 9197207fe8db140d8658aa12cd7422bfd84a001227a9f0841ebf5d92da4be531cfd7dea26aad584fff3573bc066b8fadc4e9d4e70bcc6dd5978253d94a9d66a4
7
+ data.tar.gz: 3b37c794027fcdbec12ef314bd6a927e111c2aed2044f3ead9f05893400e7221bf9adf98203efe7a225b395d5644326b943c144c13fb0caeccff5dff20a56ca5
@@ -5,9 +5,39 @@ upgrade guides.
5
5
 
6
6
  User-visible changes worth mentioning.
7
7
 
8
- ## 5.3.2
8
+ ## master
9
9
 
10
- - [#1371] Backport: add `#as_json` method and attributes serialization restriction for Application model.
10
+ - [#PR ID] Add your PR description here.
11
+
12
+ ## 5.5.0.rc1
13
+
14
+ - [#1435] Make error response not redirectable when client is unauthorized
15
+ - [#1426] Ensure ActiveRecord callbacks are executed on token revocation.
16
+ - [#1407] Remove redundant and complex to support helpers froms tests (`should_have_json`, etc).
17
+ - [#1416] Don't add introspection route if token introspection completely disabled.
18
+ - [#1410] Properly memoize `current_resource_owner` value (consider `nil` and `false` values).
19
+ - [#1415] Ignore PKCE params for non-PKCE grants.
20
+ - [#1418] Add ability to register custom OAuth Grant Flows.
21
+ - [#1420] Require client authentication for Resource Owner Password Grant as stated in OAuth RFC.
22
+
23
+ **[IMPORTANT]** you need to create a new OAuth client (`Doorkeeper::Application`) if yoo didn't
24
+ have it before and use client credentials in HTTP Basic auth if you previously used this grant
25
+ flow without client authentication. For migration purposes you could enable
26
+ `skip_client_authentication_for_password_grant` configuration option to `true`, but such behavior
27
+ (as well as configuration option) would be completely removed in a future version of Doorkeeper.
28
+ All the users of your provider application now need to include client credentials when they use
29
+ this grant flow.
30
+
31
+ - [#1421] Add Resource Owner instance to authorization hook context for `custom_access_token_expires_in`
32
+ configuration option to allow resource owner based Access Tokens TTL.
33
+
34
+ ## 5.4.0
35
+
36
+ - [#1404] Make `Doorkeeper::Application#read_attribute_for_serialization` public.
37
+
38
+ ## 5.4.0.rc2
39
+
40
+ - [#1371] Add `#as_json` method and attributes serialization restriction for Application model.
11
41
  Fixes information disclosure vulnerability (CVE-2020-10187).
12
42
 
13
43
  **[IMPORTANT]** you need to re-implement `#as_json` method for Doorkeeper Application model
@@ -15,6 +45,54 @@ User-visible changes worth mentioning.
15
45
  JSON response from /oauth/applications.json or /oauth/authorized_applications.json. This change
16
46
  is a breaking change which restricts serialized attributes to a very small set of columns.
17
47
 
48
+ - [#1395] Fix `NameError: uninitialized constant Doorkeeper::AccessToken` for Rake tasks.
49
+ - [#1397] Add `as: :doorkeeper_application` on Doorkeeper application form in order to support
50
+ custom configured application model.
51
+ - [#1400] Correctly yield the application instance to `allow_grant_flow_for_client?` config
52
+ option (fixes #1398).
53
+ - [#1402] Handle trying authorization with client credentials.
54
+
55
+ ## 5.4.0.rc1
56
+ - [#1366] Sets expiry of token generated using `refresh_token` to that of original token. (Fixes #1364)
57
+ - [#1354] Add `authorize_resource_owner_for_client` option to authorize the calling user to access an application.
58
+ - [#1355] Allow to enable polymorphic Resource Owner association for Access Token & Grant
59
+ models (`use_polymorphic_resource_owner` configuration option).
60
+
61
+ **[IMPORTANT]** Review your custom patches or extensions for Doorkeeper internals if you
62
+ have such - since now Doorkeeper passes Resource Owner instance to every objects and not
63
+ just it's ID. See PR description for details.
64
+
65
+ - [#1356] Remove duplicated scopes from Access Tokens and Grants on attribute assignment.
66
+ - [#1357] Fix `Doorkeeper::OAuth::PreAuthorization#as_json` method causing
67
+ `Stack level too deep` error with AMS (fix #1312).
68
+ - [#1358] Deprecate `active_record_options` configuration option.
69
+ - [#1359] Refactor Doorkeeper configuration options DSL to make it easy to reuse it
70
+ in external extensions.
71
+ - [#1360] Increase `matching_token_for` lookup size to 10 000 and make it configurable.
72
+ - [#1371] Fix controllers to use valid classes in case Doorkeeper has custom models configured.
73
+ - [#1370] Fix revocation response for invalid token and unauthorized requests to conform with RFC 7009 (fixes #1362).
74
+
75
+ **[IMPORTANT]** now fully according to RFC 7009 nobody can do a revocation request without `client_id`
76
+ (for public clients) and `client_secret` (for private clients). Please update your apps to include that
77
+ info in the revocation request payload.
78
+
79
+ - [#1373] Make Doorkeeper routes mapper reusable in extensions.
80
+ - [#1374] Revoke and issue client credentials token in a transaction with a row lock.
81
+ - [#1384] Add context object with auth/pre_auth and issued_token for authorization hooks.
82
+ - [#1387] Add `AccessToken#create_for` and use in `RefreshTokenRequest`.
83
+ - [#1392] Fix `enable_polymorphic_resource_owner` migration template to have proper index name.
84
+ - [#1393] Improve Applications #show page with more informative data on client secret and scopes.
85
+ - [#1394] Use Ruby `autoload` feature to load Doorkeeper files.
86
+
87
+ ## 5.3.3
88
+
89
+ - [#1404] Backport: Make `Doorkeeper::Application#read_attribute_for_serialization` public.
90
+
91
+ ## 5.3.2
92
+
93
+ - [#1371] Backport: add `#as_json` method and attributes serialization restriction for Application model.
94
+ Fixes information disclosure vulnerability (CVE-2020-10187).
95
+
18
96
  ## 5.3.1
19
97
 
20
98
  - [#1360] Backport: Increase `matching_token_for` batch lookup size to 10 000 and make it configurable.
@@ -33,6 +111,15 @@ User-visible changes worth mentioning.
33
111
  If you were relying on access tokens being revoked once the same client
34
112
  requested a new access token, reenable it with `revoke_previous_client_credentials_token` in Doorkeeper
35
113
  initialization file.
114
+
115
+ ## 5.2.6
116
+
117
+ - [#1404] Backport: Make `Doorkeeper::Application#read_attribute_for_serialization` public.
118
+
119
+ ## 5.2.5
120
+
121
+ - [#1371] Backport: add `#as_json` method and attributes serialization restriction for Application model.
122
+ Fixes information disclosure vulnerability (CVE-2020-10187).
36
123
 
37
124
  ## 5.2.4
38
125
 
@@ -66,6 +153,9 @@ User-visible changes worth mentioning.
66
153
  - [#1298] Slice strong params so doesn't error with Rails forms.
67
154
  - [#1300] Limiting access to attributes of pre_authorization.
68
155
  - [#1296] Adding client_id to strong parameters.
156
+
157
+ **[IMPORTANT]** `Doorkeeper::Server#client_via_uid` was removed.
158
+
69
159
  - [#1293] Move ar specific redirect uri validator to ar orm directory.
70
160
  - [#1288] Allow to pass attributes to the `Doorkeeper::OAuth::PreAuthorization#as_json` method to customize
71
161
  the PreAuthorization response.
@@ -98,6 +188,15 @@ User-visible changes worth mentioning.
98
188
  - [#1248] Return the unhashed Application Secret in the JSON response after creating new application even when `hash_application_secrets` is used.
99
189
  - [#1238] Better support for native app with support for custom scheme and localhost redirection.
100
190
 
191
+ ## 5.1.2
192
+
193
+ - [#1404] Backport: Make `Doorkeeper::Application#read_attribute_for_serialization` public.
194
+
195
+ ## 5.1.1
196
+
197
+ - [#1371] Backport: add `#as_json` method and attributes serialization restriction for Application model.
198
+ Fixes information disclosure vulnerability (CVE-2020-10187).
199
+
101
200
  ## 5.1.0
102
201
 
103
202
  - [#1243] Add nil check operator in token checking at token introspection.
@@ -159,6 +258,11 @@ User-visible changes worth mentioning.
159
258
  - [#1164] Fix error when `root_path` is not defined.
160
259
  - [#1162] Fix `enforce_content_type` for requests without body.
161
260
 
261
+ ## 5.0.3
262
+
263
+ - [#1371] Backport: add `#as_json` method and attributes serialization restriction for Application model.
264
+ Fixes information disclosure vulnerability (CVE-2020-10187).
265
+
162
266
  ## 5.0.2
163
267
 
164
268
  - [#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.production.guardrails.io/doorkeeper-gem/doorkeeper.svg?token=66768ce8f6995814df81f65a2cff40f739f688492704f973e62809e15599bb62)](https://dashboard.guardrails.io/default/gh/doorkeeper-gem/doorkeeper)
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
- | oAuth2 Server with Doorkeeper | [doorkeeper-gem/doorkeeper-provider-app](https://github.com/doorkeeper-gem/doorkeeper-provider-app) |
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 = Application.ordered_by(:created_at)
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 = Application.new
27
+ @application = Doorkeeper.config.application_model.new
28
28
  end
29
29
 
30
30
  def create
31
- @application = Application.new(application_params)
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 = Application.find(params[:id])
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
- AccessToken.matching_token_for(
45
+ Doorkeeper.config.access_token_model.matching_token_for(
46
46
  pre_auth.client,
47
- current_resource_owner.id,
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(Doorkeeper.configuration, pre_auth_params)
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,15 @@ module Doorkeeper
73
77
  end
74
78
 
75
79
  def pre_auth_param_fields
76
- %i[client_id response_type redirect_uri scope state code_challenge
77
- code_challenge_method]
80
+ %i[
81
+ client_id
82
+ code_challenge
83
+ code_challenge_method
84
+ response_type
85
+ redirect_uri
86
+ scope
87
+ state
88
+ ]
78
89
  end
79
90
 
80
91
  def authorization
@@ -82,26 +93,35 @@ module Doorkeeper
82
93
  end
83
94
 
84
95
  def strategy
85
- @strategy ||= server.authorization_request pre_auth.response_type
96
+ @strategy ||= server.authorization_request(pre_auth.response_type)
86
97
  end
87
98
 
88
99
  def authorize_response
89
100
  @authorize_response ||= begin
90
101
  return pre_auth.error_response unless pre_auth.authorizable?
91
102
 
92
- before_successful_authorization
103
+ context = build_context(pre_auth: pre_auth)
104
+ before_successful_authorization(context)
105
+
93
106
  auth = strategy.authorize
94
- after_successful_authorization
107
+
108
+ context = build_context(auth: auth)
109
+ after_successful_authorization(context)
110
+
95
111
  auth
96
112
  end
97
113
  end
98
114
 
99
- def after_successful_authorization
100
- Doorkeeper.configuration.after_successful_authorization.call(self)
115
+ def build_context(**attributes)
116
+ Doorkeeper::OAuth::Hooks::Context.new(**attributes)
117
+ end
118
+
119
+ def before_successful_authorization(context = nil)
120
+ Doorkeeper.config.before_successful_authorization.call(self, context)
101
121
  end
102
122
 
103
- def before_successful_authorization
104
- Doorkeeper.configuration.before_successful_authorization.call(self)
123
+ def after_successful_authorization(context)
124
+ Doorkeeper.config.after_successful_authorization.call(self, context)
105
125
  end
106
126
  end
107
127
  end
@@ -5,7 +5,7 @@ module Doorkeeper
5
5
  before_action :authenticate_resource_owner!
6
6
 
7
7
  def index
8
- @applications = Application.authorized_for(current_resource_owner)
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
- Application.revoke_tokens_and_grants_for(
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
- # The authorization server, if applicable, first authenticates the client
16
- # and checks its ownership of the provided token.
15
+ # @see 2.1. Revocation Request
17
16
  #
18
- # Doorkeeper does not use the token_type_hint logic described in the
19
- # RFC 7009 due to the refresh token implementation that is a field in
20
- # the access token model.
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 authorized?
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,15 @@ module Doorkeeper
42
69
  private
43
70
 
44
71
  # OAuth 2.0 Section 2.1 defines two client types, "public" & "confidential".
45
- # Public clients (as per RFC 7009) do not require authentication whereas
46
- # confidential clients must be authenticated for their token revocation.
72
+ #
73
+ # RFC7009
74
+ # Section 5. Security Considerations
75
+ # A malicious client may attempt to guess valid tokens on this endpoint
76
+ # by making revocation requests against potential token strings.
77
+ # According to this specification, a client's request must contain a
78
+ # valid client_id, in the case of a public client, or valid client
79
+ # credentials, in the case of a confidential client. The token being
80
+ # revoked must also belong to the requesting client.
47
81
  #
48
82
  # Once a confidential client is authenticated, it must be authorized to
49
83
  # revoke the provided access or refresh token. This ensures one client
@@ -58,15 +92,13 @@ module Doorkeeper
58
92
  # https://tools.ietf.org/html/rfc6749#section-2.1
59
93
  # https://tools.ietf.org/html/rfc7009
60
94
  def authorized?
61
- return unless token.present?
62
-
63
- # Client is confidential, therefore client authentication & authorization
64
- # is required
95
+ # Token belongs to specific client, so we need to check if
96
+ # authenticated client could access it.
65
97
  if token.application_id? && token.application.confidential?
66
98
  # We authorize client by checking token's application
67
99
  server.client && server.client.application == token.application
68
100
  else
69
- # Client is public, authentication unnecessary
101
+ # Token was issued without client, authorization unnecessary
70
102
  true
71
103
  end
72
104
  end
@@ -78,9 +110,12 @@ module Doorkeeper
78
110
  token.revoke if token&.accessible?
79
111
  end
80
112
 
113
+ # Doorkeeper does not use the token_type_hint logic described in the
114
+ # RFC 7009 due to the refresh token implementation that is a field in
115
+ # the access token model.
81
116
  def token
82
- @token ||= AccessToken.by_token(params["token"]) ||
83
- AccessToken.by_refresh_token(params["token"])
117
+ @token ||= Doorkeeper.config.access_token_model.by_token(params["token"]) ||
118
+ Doorkeeper.config.access_token_model.by_refresh_token(params["token"])
84
119
  end
85
120
 
86
121
  def strategy
@@ -91,17 +126,22 @@ module Doorkeeper
91
126
  @authorize_response ||= begin
92
127
  before_successful_authorization
93
128
  auth = strategy.authorize
94
- after_successful_authorization unless auth.is_a?(Doorkeeper::OAuth::ErrorResponse)
129
+ context = build_context(auth: auth)
130
+ after_successful_authorization(context) unless auth.is_a?(Doorkeeper::OAuth::ErrorResponse)
95
131
  auth
96
132
  end
97
133
  end
98
134
 
99
- def after_successful_authorization
100
- Doorkeeper.configuration.after_successful_authorization.call(self)
135
+ def build_context(**attributes)
136
+ Doorkeeper::OAuth::Hooks::Context.new(**attributes)
137
+ end
138
+
139
+ def before_successful_authorization(context = nil)
140
+ Doorkeeper.config.before_successful_authorization.call(self, context)
101
141
  end
102
142
 
103
- def before_successful_authorization
104
- Doorkeeper.configuration.before_successful_authorization.call(self)
143
+ def after_successful_authorization(context)
144
+ Doorkeeper.config.after_successful_authorization.call(self, context)
105
145
  end
106
146
 
107
147
  def revocation_error_response