Skip to content

Use JWK set URI for imperative OAuth2 decoder#32692

Open
ruggeropaolobasile wants to merge 1 commit intojhipster:mainfrom
ruggeropaolobasile:fix/oidc-jwk-timeout
Open

Use JWK set URI for imperative OAuth2 decoder#32692
ruggeropaolobasile wants to merge 1 commit intojhipster:mainfrom
ruggeropaolobasile:fix/oidc-jwk-timeout

Conversation

@ruggeropaolobasile
Copy link

What does this PR do?

This changes the imperative OAuth2 security template to build the NimbusJwtDecoder directly from the generated OIDC client registration JWK Set URI instead of calling JwtDecoders.fromOidcIssuerLocation(issuerUri).

That avoids the Spring Security discovery/JWK retrieval path that can fail with socket timeouts on slow connections, while still preserving the existing issuer and audience validation.

It also wires the decoder through RestTemplateBuilder, so timeout customization can hook into the standard Spring client path used by the generated application.

Why is this needed?

In the generated imperative OAuth2 setup, startup currently depends on the OIDC discovery flow completing quickly enough. On slow connections this can fail with RemoteKeySourceException / SocketTimeoutException, which is the problem described in #17550.

The reactive non-microservice branch already works from an explicit jwkSetUri; this aligns the imperative branch with that approach.

Test plan

Verified locally:

  • npm run lint
  • npm run check-types

I also attempted to run the focused Spring Boot generator tests locally, but the JHipster test harness in this environment is affected by local generator lookup assumptions unrelated to this patch, so I could not get a reliable targeted snapshot run from the repo tooling.

Related issue

Fixes #17550

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On a slow internet connection, Okta/Auth0 JWK retrieval API fails with socket timeout

1 participant