Closed
Description
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.
- Start a webflux app with resource server and spring security.
- Set spring.security.oauth2.resourceserver.jwt.issuer-uri to any url, e.g. http://localhost:1, which is not working
- Send a request with any jwt token
- You will see exception logging in console like Connection refused: no further information
- Set a breakpoint at line 103 in ReactiveRemoteJWKSource
- Send the request again
- 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.