Skip to content

Commit 17387b2

Browse files
Copilotnbulaj
andcommitted
Derive token_endpoint_auth_methods_supported from Doorkeeper client_credentials config
Co-authored-by: nbulaj <1443426+nbulaj@users.noreply.github.com>
1 parent 09f2cd7 commit 17387b2

7,388 files changed

Lines changed: 1396187 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/controllers/doorkeeper/openid_connect/discovery_controller.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def provider_response
4747
# TODO: look into doorkeeper-jwt_assertion for these
4848
# 'client_secret_jwt',
4949
# 'private_key_jwt'
50-
token_endpoint_auth_methods_supported: %w[client_secret_basic client_secret_post],
50+
token_endpoint_auth_methods_supported: token_endpoint_auth_methods_supported(doorkeeper),
5151

5252
subject_types_supported: openid_connect.subject_types_supported,
5353

@@ -79,6 +79,11 @@ def response_modes_supported(doorkeeper)
7979
doorkeeper.authorization_response_flows.flat_map(&:response_mode_matches).uniq
8080
end
8181

82+
def token_endpoint_auth_methods_supported(doorkeeper)
83+
mapping = { from_basic: 'client_secret_basic', from_params: 'client_secret_post' }
84+
doorkeeper.client_credentials_methods.filter_map { |method| mapping[method] }
85+
end
86+
8287
def code_challenge_methods_supported(doorkeeper)
8388
return unless doorkeeper.access_grant_model.pkce_supported?
8489

spec/controllers/discovery_controller_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,39 @@
158158
end
159159
end
160160

161+
context 'when client_credentials is configured with only from_basic' do
162+
before { Doorkeeper.configure { client_credentials :from_basic } }
163+
164+
it 'returns only client_secret_basic in token_endpoint_auth_methods_supported' do
165+
get :provider
166+
data = JSON.parse(response.body)
167+
168+
expect(data['token_endpoint_auth_methods_supported']).to eq %w[client_secret_basic]
169+
end
170+
end
171+
172+
context 'when client_credentials is configured with only from_params' do
173+
before { Doorkeeper.configure { client_credentials :from_params } }
174+
175+
it 'returns only client_secret_post in token_endpoint_auth_methods_supported' do
176+
get :provider
177+
data = JSON.parse(response.body)
178+
179+
expect(data['token_endpoint_auth_methods_supported']).to eq %w[client_secret_post]
180+
end
181+
end
182+
183+
context 'when client_credentials is configured with both from_basic and from_params' do
184+
before { Doorkeeper.configure { client_credentials :from_basic, :from_params } }
185+
186+
it 'returns both client_secret_basic and client_secret_post in token_endpoint_auth_methods_supported' do
187+
get :provider
188+
data = JSON.parse(response.body)
189+
190+
expect(data['token_endpoint_auth_methods_supported']).to eq %w[client_secret_basic client_secret_post]
191+
end
192+
end
193+
161194
context 'when grant_flows is configed with authorization_code and implicit flow' do
162195
before { Doorkeeper.configure { grant_flows %w[authorization_code implicit_oidc] } }
163196

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby3.2
2+
#
3+
# This file was generated by RubyGems.
4+
#
5+
# The application 'byebug' is installed as part of a gem, and
6+
# this file is here to facilitate running it.
7+
#
8+
9+
require 'rubygems'
10+
11+
Gem.use_gemdeps
12+
13+
version = ">= 0.a"
14+
15+
str = ARGV.first
16+
if str
17+
str = str.b[/\A_(.*)_\z/, 1]
18+
if str and Gem::Version.correct?(str)
19+
version = str
20+
ARGV.shift
21+
end
22+
end
23+
24+
if Gem.respond_to?(:activate_bin_path)
25+
load Gem.activate_bin_path('byebug', 'byebug', version)
26+
else
27+
gem "byebug", version
28+
load Gem.bin_path("byebug", "byebug", version)
29+
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby3.2
2+
#
3+
# This file was generated by RubyGems.
4+
#
5+
# The application 'coderay' is installed as part of a gem, and
6+
# this file is here to facilitate running it.
7+
#
8+
9+
require 'rubygems'
10+
11+
Gem.use_gemdeps
12+
13+
version = ">= 0.a"
14+
15+
str = ARGV.first
16+
if str
17+
str = str.b[/\A_(.*)_\z/, 1]
18+
if str and Gem::Version.correct?(str)
19+
version = str
20+
ARGV.shift
21+
end
22+
end
23+
24+
if Gem.respond_to?(:activate_bin_path)
25+
load Gem.activate_bin_path('coderay', 'coderay', version)
26+
else
27+
gem "coderay", version
28+
load Gem.bin_path("coderay", "coderay", version)
29+
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby3.2
2+
#
3+
# This file was generated by RubyGems.
4+
#
5+
# The application 'conventional-changelog' is installed as part of a gem, and
6+
# this file is here to facilitate running it.
7+
#
8+
9+
require 'rubygems'
10+
11+
Gem.use_gemdeps
12+
13+
version = ">= 0.a"
14+
15+
str = ARGV.first
16+
if str
17+
str = str.b[/\A_(.*)_\z/, 1]
18+
if str and Gem::Version.correct?(str)
19+
version = str
20+
ARGV.shift
21+
end
22+
end
23+
24+
if Gem.respond_to?(:activate_bin_path)
25+
load Gem.activate_bin_path('conventional-changelog', 'conventional-changelog', version)
26+
else
27+
gem "conventional-changelog", version
28+
load Gem.bin_path("conventional-changelog", "conventional-changelog", version)
29+
end

vendor/bundle/ruby/3.2.0/bin/erb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby3.2
2+
#
3+
# This file was generated by RubyGems.
4+
#
5+
# The application 'erb' is installed as part of a gem, and
6+
# this file is here to facilitate running it.
7+
#
8+
9+
require 'rubygems'
10+
11+
Gem.use_gemdeps
12+
13+
version = ">= 0.a"
14+
15+
str = ARGV.first
16+
if str
17+
str = str.b[/\A_(.*)_\z/, 1]
18+
if str and Gem::Version.correct?(str)
19+
version = str
20+
ARGV.shift
21+
end
22+
end
23+
24+
if Gem.respond_to?(:activate_bin_path)
25+
load Gem.activate_bin_path('erb', 'erb', version)
26+
else
27+
gem "erb", version
28+
load Gem.bin_path("erb", "erb", version)
29+
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby3.2
2+
#
3+
# This file was generated by RubyGems.
4+
#
5+
# The application 'diff-lcs' is installed as part of a gem, and
6+
# this file is here to facilitate running it.
7+
#
8+
9+
require 'rubygems'
10+
11+
Gem.use_gemdeps
12+
13+
version = ">= 0.a"
14+
15+
str = ARGV.first
16+
if str
17+
str = str.b[/\A_(.*)_\z/, 1]
18+
if str and Gem::Version.correct?(str)
19+
version = str
20+
ARGV.shift
21+
end
22+
end
23+
24+
if Gem.respond_to?(:activate_bin_path)
25+
load Gem.activate_bin_path('diff-lcs', 'htmldiff', version)
26+
else
27+
gem "diff-lcs", version
28+
load Gem.bin_path("diff-lcs", "htmldiff", version)
29+
end

vendor/bundle/ruby/3.2.0/bin/irb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby3.2
2+
#
3+
# This file was generated by RubyGems.
4+
#
5+
# The application 'irb' is installed as part of a gem, and
6+
# this file is here to facilitate running it.
7+
#
8+
9+
require 'rubygems'
10+
11+
Gem.use_gemdeps
12+
13+
version = ">= 0.a"
14+
15+
str = ARGV.first
16+
if str
17+
str = str.b[/\A_(.*)_\z/, 1]
18+
if str and Gem::Version.correct?(str)
19+
version = str
20+
ARGV.shift
21+
end
22+
end
23+
24+
if Gem.respond_to?(:activate_bin_path)
25+
load Gem.activate_bin_path('irb', 'irb', version)
26+
else
27+
gem "irb", version
28+
load Gem.bin_path("irb", "irb", version)
29+
end

vendor/bundle/ruby/3.2.0/bin/ldiff

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby3.2
2+
#
3+
# This file was generated by RubyGems.
4+
#
5+
# The application 'diff-lcs' is installed as part of a gem, and
6+
# this file is here to facilitate running it.
7+
#
8+
9+
require 'rubygems'
10+
11+
Gem.use_gemdeps
12+
13+
version = ">= 0.a"
14+
15+
str = ARGV.first
16+
if str
17+
str = str.b[/\A_(.*)_\z/, 1]
18+
if str and Gem::Version.correct?(str)
19+
version = str
20+
ARGV.shift
21+
end
22+
end
23+
24+
if Gem.respond_to?(:activate_bin_path)
25+
load Gem.activate_bin_path('diff-lcs', 'ldiff', version)
26+
else
27+
gem "diff-lcs", version
28+
load Gem.bin_path("diff-lcs", "ldiff", version)
29+
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby3.2
2+
#
3+
# This file was generated by RubyGems.
4+
#
5+
# The application 'minitest' is installed as part of a gem, and
6+
# this file is here to facilitate running it.
7+
#
8+
9+
require 'rubygems'
10+
11+
Gem.use_gemdeps
12+
13+
version = ">= 0.a"
14+
15+
str = ARGV.first
16+
if str
17+
str = str.b[/\A_(.*)_\z/, 1]
18+
if str and Gem::Version.correct?(str)
19+
version = str
20+
ARGV.shift
21+
end
22+
end
23+
24+
if Gem.respond_to?(:activate_bin_path)
25+
load Gem.activate_bin_path('minitest', 'minitest', version)
26+
else
27+
gem "minitest", version
28+
load Gem.bin_path("minitest", "minitest", version)
29+
end

0 commit comments

Comments
 (0)