I want to cache the content of jwkSetUri, and found it would be feasible to change the private function buildDecoder in OidcIdTokenDecoderFactory like the following.
private CachedNimbusJwtDecoder buildDecoder(ClientRegistration clientRegistration) {
val jwkSetCache = ConcurrentMapCache(
"jwkSetCache",
CacheBuilder.newBuilder()
.expireAfterWrite(Duration.ofMinutes(jwkCacheTtl.cacheTtlMin))
.build<Any, Any>().asMap(),
false
)
return NimbusJwtDecoder.withJwkSetUri(jwkSetUri).cache(jwkSetCache).jwsAlgorithm((SignatureAlgorithm) jwsAlgorithm).build();
}
The issue is I would need to copy the whole content of OidcIdTokenDecoderFactory by implementing JwtDecoderFactory doing this way.
Is there maybe a way to inject a CachedJwtDecoder and let OidcIdTokenDecoderFactory use it?
Any other alternative is also very welcome.