doorkeeper 5.9.7 → 6.0.0.beta1

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -12
  3. data/README.md +1 -0
  4. data/app/controllers/doorkeeper/metadata_controller.rb +20 -0
  5. data/app/controllers/doorkeeper/tokens_controller.rb +10 -1
  6. data/app/views/doorkeeper/authorizations/new.html.erb +6 -0
  7. data/lib/doorkeeper/client_authentication/credentials.rb +11 -0
  8. data/lib/doorkeeper/client_authentication/fallback_method.rb +19 -0
  9. data/lib/doorkeeper/client_authentication/legacy_callable.rb +46 -0
  10. data/lib/doorkeeper/client_authentication/method.rb +23 -0
  11. data/lib/doorkeeper/client_authentication/registry.rb +47 -0
  12. data/lib/doorkeeper/client_authentication.rb +93 -0
  13. data/lib/doorkeeper/config/option.rb +1 -1
  14. data/lib/doorkeeper/config/validations.rb +162 -1
  15. data/lib/doorkeeper/config.rb +113 -12
  16. data/lib/doorkeeper/errors.rb +1 -0
  17. data/lib/doorkeeper/models/access_token_mixin.rb +40 -5
  18. data/lib/doorkeeper/models/application_mixin.rb +14 -6
  19. data/lib/doorkeeper/models/concerns/secret_storable.rb +10 -1
  20. data/lib/doorkeeper/oauth/authorization/uri_builder.rb +11 -0
  21. data/lib/doorkeeper/oauth/authorization_code_request.rb +4 -1
  22. data/lib/doorkeeper/oauth/client.rb +18 -0
  23. data/lib/doorkeeper/oauth/client_authentication/client_secret_basic.rb +53 -0
  24. data/lib/doorkeeper/oauth/client_authentication/client_secret_post.rb +29 -0
  25. data/lib/doorkeeper/oauth/client_authentication/none.rb +32 -0
  26. data/lib/doorkeeper/oauth/code_response.rb +16 -2
  27. data/lib/doorkeeper/oauth/error_response.rb +11 -2
  28. data/lib/doorkeeper/oauth/metadata_response.rb +157 -0
  29. data/lib/doorkeeper/oauth/pre_authorization.rb +12 -5
  30. data/lib/doorkeeper/oauth/token.rb +0 -76
  31. data/lib/doorkeeper/oauth/token_introspection.rb +27 -7
  32. data/lib/doorkeeper/orm/active_record/mixins/application.rb +2 -2
  33. data/lib/doorkeeper/rails/routes/mapping.rb +1 -0
  34. data/lib/doorkeeper/rails/routes.rb +6 -0
  35. data/lib/doorkeeper/request.rb +59 -0
  36. data/lib/doorkeeper/server.rb +5 -2
  37. data/lib/doorkeeper/version.rb +4 -4
  38. data/lib/doorkeeper.rb +8 -4
  39. data/lib/generators/doorkeeper/templates/initializer.rb +65 -13
  40. metadata +14 -7
  41. data/lib/doorkeeper/oauth/client/credentials.rb +0 -86
metadata CHANGED
@@ -1,17 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doorkeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.9.7
4
+ version: 6.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Elias Philipp
8
8
  - Tute Costa
9
9
  - Jon Moss
10
10
  - Nikita Bulai
11
- autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2026-09-10 00:00:00.000000000 Z
13
+ date: 1980-01-02 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: railties
@@ -184,6 +183,7 @@ files:
184
183
  - app/controllers/doorkeeper/applications_controller.rb
185
184
  - app/controllers/doorkeeper/authorizations_controller.rb
186
185
  - app/controllers/doorkeeper/authorized_applications_controller.rb
186
+ - app/controllers/doorkeeper/metadata_controller.rb
187
187
  - app/controllers/doorkeeper/token_info_controller.rb
188
188
  - app/controllers/doorkeeper/tokens_controller.rb
189
189
  - app/helpers/doorkeeper/dashboard_helper.rb
@@ -203,6 +203,12 @@ files:
203
203
  - app/views/layouts/doorkeeper/application.html.erb
204
204
  - config/locales/en.yml
205
205
  - lib/doorkeeper.rb
206
+ - lib/doorkeeper/client_authentication.rb
207
+ - lib/doorkeeper/client_authentication/credentials.rb
208
+ - lib/doorkeeper/client_authentication/fallback_method.rb
209
+ - lib/doorkeeper/client_authentication/legacy_callable.rb
210
+ - lib/doorkeeper/client_authentication/method.rb
211
+ - lib/doorkeeper/client_authentication/registry.rb
206
212
  - lib/doorkeeper/config.rb
207
213
  - lib/doorkeeper/config/abstract_builder.rb
208
214
  - lib/doorkeeper/config/option.rb
@@ -240,7 +246,9 @@ files:
240
246
  - lib/doorkeeper/oauth/base_request.rb
241
247
  - lib/doorkeeper/oauth/base_response.rb
242
248
  - lib/doorkeeper/oauth/client.rb
243
- - lib/doorkeeper/oauth/client/credentials.rb
249
+ - lib/doorkeeper/oauth/client_authentication/client_secret_basic.rb
250
+ - lib/doorkeeper/oauth/client_authentication/client_secret_post.rb
251
+ - lib/doorkeeper/oauth/client_authentication/none.rb
244
252
  - lib/doorkeeper/oauth/client_credentials/creator.rb
245
253
  - lib/doorkeeper/oauth/client_credentials/issuer.rb
246
254
  - lib/doorkeeper/oauth/client_credentials/validator.rb
@@ -256,6 +264,7 @@ files:
256
264
  - lib/doorkeeper/oauth/hooks/context.rb
257
265
  - lib/doorkeeper/oauth/invalid_request_response.rb
258
266
  - lib/doorkeeper/oauth/invalid_token_response.rb
267
+ - lib/doorkeeper/oauth/metadata_response.rb
259
268
  - lib/doorkeeper/oauth/nonstandard.rb
260
269
  - lib/doorkeeper/oauth/password_access_token_request.rb
261
270
  - lib/doorkeeper/oauth/pre_authorization.rb
@@ -330,7 +339,6 @@ metadata:
330
339
  bug_tracker_uri: https://github.com/doorkeeper-gem/doorkeeper/issues
331
340
  documentation_uri: https://doorkeeper.gitbook.io/guides/
332
341
  funding_uri: https://opencollective.com/doorkeeper-gem
333
- post_install_message:
334
342
  rdoc_options: []
335
343
  require_paths:
336
344
  - lib
@@ -345,8 +353,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
345
353
  - !ruby/object:Gem::Version
346
354
  version: '0'
347
355
  requirements: []
348
- rubygems_version: 3.5.16
349
- signing_key:
356
+ rubygems_version: 4.0.11
350
357
  specification_version: 4
351
358
  summary: OAuth 2 provider for Rails and Grape
352
359
  test_files: []
@@ -1,86 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Doorkeeper
4
- module OAuth
5
- class Client
6
- Credentials = Struct.new(:uid, :secret) do
7
- class << self
8
- # Extracts the client credentials from the request using the
9
- # configured extraction methods. The first method that yields
10
- # credentials wins, as it always has.
11
- #
12
- # Raises Errors::MultipleClientAuthMethods when the request
13
- # authenticates the client with more than one method, or presents
14
- # more than one client identity, which RFC 6749 §2.3 forbids ("The
15
- # client MUST NOT use more than one authentication method in each
16
- # request").
17
- def from_request(request, *credentials_methods)
18
- # Callable extractors are opaque: they may legitimately overlap the
19
- # built-in methods they are configured with, and evaluating all of
20
- # them would also break the existing contract that the extractors
21
- # after the matching one are not called. Such configurations keep
22
- # the historical behaviour untouched, including the fact that a
23
- # request authenticating with more than one method, or presenting
24
- # more than one client identity, resolves to the first extracted
25
- # credentials instead of being rejected: the extractor that would
26
- # have surfaced the second identity is never evaluated. The
27
- # +client_credentials+ configuration option documents this.
28
- return first_from_request(request, credentials_methods) unless credentials_methods.all?(Symbol)
29
-
30
- credentials = credentials_methods.filter_map { |method| extract(request, method) }
31
-
32
- # Only credentials carrying a secret authenticate the client. A bare
33
- # uid is a public client identifying itself (RFC 6749 §2.3 "none"),
34
- # not an authentication method of its own, so it doesn't count
35
- # towards the single-method rule — RFC 7521 §4.2, for example,
36
- # explicitly allows a client_id next to another authentication
37
- # method.
38
- raise Errors::MultipleClientAuthMethods if credentials.count { |c| c.secret.present? } > 1
39
-
40
- # §4.2 allows that bare client_id because it identifies the *same*
41
- # client as the authentication method it accompanies. Credentials
42
- # naming two different clients are two client identities in one
43
- # request and authenticate neither: without this check the first
44
- # extracted uid would win and the other identity would be silently
45
- # discarded, so the caller could authenticate as one client while
46
- # the request asks to act as another.
47
- raise Errors::MultipleClientAuthMethods if credentials.uniq(&:uid).size > 1
48
-
49
- credentials.first
50
- end
51
-
52
- def from_params(request)
53
- request.parameters.values_at(:client_id, :client_secret)
54
- end
55
-
56
- def from_basic(request)
57
- authorization = request.authorization
58
- if authorization.present? && authorization =~ /^Basic (.*)/im
59
- Base64.decode64(Regexp.last_match(1)).split(/:/, 2)
60
- end
61
- end
62
-
63
- private
64
-
65
- def first_from_request(request, credentials_methods)
66
- credentials_methods.inject(nil) do |_, method|
67
- credentials = extract(request, method)
68
- break credentials if credentials
69
- end
70
- end
71
-
72
- # Returns the credentials the given method extracts from the request,
73
- # or nil when it extracts none.
74
- def extract(request, method)
75
- method = self.method(method) if method.is_a?(Symbol)
76
- Credentials.new(*method.call(request)).presence
77
- end
78
- end
79
-
80
- # Public clients may have their secret blank, but "credentials" are
81
- # still present
82
- delegate :blank?, to: :uid
83
- end
84
- end
85
- end
86
- end