Skip to content

ReactiveRemoteJWKSource caches invalid response status into jwkSetURL #13757

Closed
@dongelci

Description

@dongelci

Describe the bug
ReactiveRemoteJWKSource receives a Mono for jwkSetURL, which will be lazy loaded. After invoking webClient in

private Mono<JWKSet> getJWKSet()

response will be parsed and cached separately in cachedJWKSet in success case and then cached again in line 111, which causes the trouble. If IDM is not reachable at that point of time, cache() call on jwkSetURL Mono caches an error state, which is never invalidated.

To Reproduce
It should be debugged inside ReactiveRemoteJWKSource.

  1. Start a webflux app with resource server and spring security.
  2. Set spring.security.oauth2.resourceserver.jwt.issuer-uri to any url, e.g. http://localhost:1, which is not working
  3. Send a request with any jwt token
  4. You will see exception logging in console like Connection refused: no further information
  5. Set a breakpoint at line 103 in ReactiveRemoteJWKSource
  6. Send the request again
  7. An IllegalArgumentException with cause WebClientRequestException is cached inside jwkSetURL

Expected behavior
If jwkSetUrl should not cache error cases. There is no reason to cache a parsed object into jwkSetURL, since it is only for a url or url string depending on the name, not an object.

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)status: duplicateA duplicate of another issuetype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions