Skip to content

Commit ad8c49a

Browse files
committed
Add Docs
Issue gh-8332
1 parent 10aa974 commit ad8c49a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/manual/src/docs/asciidoc/_includes/servlet/oauth2/oauth2-resourceserver.adoc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,27 @@ public JwtDecoder jwtDecoder(RestTemplateBuilder builder) {
10251025
}
10261026
```
10271027

1028+
Also by default, Resource Server caches in-memory the authorization server's JWK set for 5 minutes, which you may want to adjust.
1029+
Further, it doesn't take into account more sophisticated caching patterns like eviction or using a shared cache.
1030+
1031+
To adjust the way in which Resource Server caches the JWK set, `NimbusJwtDecoder` accepts an instance of `Cache`:
1032+
1033+
```java
1034+
@Bean
1035+
public JwtDecoder jwtDecoder(CacheManager cacheManager) {
1036+
return NimbusJwtDecoder.withJwtSetUri(jwkSetUri)
1037+
.cache(cacheManager.getCache("jwks"))
1038+
.build();
1039+
}
1040+
```
1041+
1042+
When given a `Cache`, Resource Server will use the JWK Set Uri as the key and the JWK Set JSON as the value.
1043+
1044+
NOTE: Spring isn't a cache provider, so you'll need to make sure to include the appropriate dependencies, like `spring-boot-starter-cache` and your favorite caching provider.
1045+
1046+
NOTE: Whether it's socket or cache timeouts, you may instead want to work with Nimbus directly.
1047+
To do so, remember that `NimbusJwtDecoder` ships with a constructor that takes Nimbus's `JWTProcessor`.
1048+
10281049
[[oauth2resourceserver-opaque-minimalconfiguration]]
10291050
=== Minimal Configuration for Introspection
10301051

0 commit comments

Comments
 (0)