Skip to content

Add SSL bundle support for JWK Set URI requests#50280

Open
bbbbooo wants to merge 2 commits intospring-projects:mainfrom
bbbbooo:jwk-set-uri-ssl-bundle
Open

Add SSL bundle support for JWK Set URI requests#50280
bbbbooo wants to merge 2 commits intospring-projects:mainfrom
bbbbooo:jwk-set-uri-ssl-bundle

Conversation

@bbbbooo
Copy link
Copy Markdown
Contributor

@bbbbooo bbbbooo commented May 2, 2026

Problem

OAuth2 Resource Server auto-configuration supports JWK Set requests via
spring.security.oauth2.resourceserver.jwt.jwk-set-uri.

However, there is no property-based way to configure the SSL context for these requests.
Applications requiring custom SSL configuration must currently provide a JwkSetUriJwtDecoderBuilderCustomizer.

Changes

  • Introduced grouped JWK Set properties under:
    • spring.security.oauth2.resourceserver.jwt.jwkset.*
  • Deprecated:
    • spring.security.oauth2.resourceserver.jwt.jwk-set-uri
  • Added new properties:
    • spring.security.oauth2.resourceserver.jwt.jwkset.uri
    • spring.security.oauth2.resourceserver.jwt.jwkset.ssl.bundle
    • spring.security.oauth2.resourceserver.jwt.jwkset.ssl.enabled
  • Enabled SSL bundle configuration for both:
    • Servlet-based JWK Set URI decoder
    • Reactive JWK Set URI decoder

Tests

Added and updated tests covering:

  • Resource server auto-configuration using jwkset.uri
  • Precedence of jwkset.uri over deprecated jwk-set-uri
  • SSL bundle configuration for both servlet and reactive decoders
  • Behavior when SSL is disabled despite bundle configuration
  • Backward compatibility with deprecated jwk-set-uri
  • Precedence of JWK Set URI over issuer URI and public key configuration

Fixes #45180

Signed-off-by: bbbbooo <hyeons1213@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 2, 2026
Copy link
Copy Markdown
Member

@philwebb philwebb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bbbbooo. I've added a few review comments for your consideration.

private void configureSsl(JwkSetUriReactiveJwtDecoderBuilder builder) {
SslBundle sslBundle = getSslBundle();
if (sslBundle != null) {
builder.webClient(webClient(sslBundle));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's quite a lot of code here that we could simplify if we add a dependency to spring-boot-webclient and use ClientHttpConnectorBuilder. I'm not sure yet if that's something we want to do. I'll flag this issue for team discussion.

@Target({ ElementType.TYPE, ElementType.METHOD })
@Documented
@Conditional(JwkSetUriCondition.class)
public @interface ConditionalOnJwkSetUriJwtDecoder {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be package-private.

* JWT decoder} should be used.
*
* @author Hyeonseok Lee
* @since 4.1.0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't make 4.1 since we're already at RC1

@philwebb philwebb added the for: team-meeting An issue we'd like to discuss as a team to make progress label May 4, 2026
Signed-off-by: bbbbooo <hyeons1213@gmail.com>
@bbbbooo
Copy link
Copy Markdown
Contributor Author

bbbbooo commented May 9, 2026

Thanks for the review.

  • Removed ConditionalOnJwkSetUriJwtDecoder.
  • Updated the servlet configuration to use the package-private JwkSetUriCondition directly.
  • Added a package-private JwkSetUriCondition in the reactive package since the existing one is not visible from
    there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

for: team-meeting An issue we'd like to discuss as a team to make progress status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow configuring an SSLBundle to use when making JWKS requests

3 participants