Description
Expected Behavior
JWKS fetching should not have influence on response times on resource server. It should be fetched immediately on start and refreshed in background without affecting request (exception being when cached jwks has no matching key).
Current Behavior
JWKS fetch (for jwks-uri) is only done after it is needed (Nimbus[Reactive]JwtDecoder
). This causes first request(s) to be delayed. Also when jwks expires it will block all request until new is fetched.
Context
This is similar (but different) to #9560.
While I agree that for WebClient this may be considered application-specific and left out of framework (though definitely would welcome it as option), I think for server side case is much stronger, as server performance and delays are more impactful, and this is causing intermittent delays for all servers configured with jwks-uri.
Envoy proxy has same issue and they reviewed it favorably as valid requirement for production environment: envoyproxy/envoy#14556, envoyproxy/envoy#14557
I think it could be reasonable default to have it enabled (with opt-out API), but opt-it API would be also ok.
There is also possibility to tie health check with jwks status, but that is separate topic maybe.