File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
services/localega-tsd-proxy/src/main/java/no/elixir/fega/ltp Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
8181 .authenticated ()
8282 .requestMatchers ("/user" )
8383 .authenticated ())
84+ .oauth2ResourceServer (oauth2 -> oauth2 .jwt (Customizer .withDefaults ()))
8485 .oauth2Login (
8586 auth ->
8687 auth .redirectionEndpoint (endpoint -> endpoint .baseUri ("/oidc-protected" ))
Original file line number Diff line number Diff line change 1+ package no .elixir .fega .ltp .config ;
2+
3+ import com .github .benmanes .caffeine .cache .Caffeine ;
4+ import java .util .concurrent .TimeUnit ;
5+ import org .springframework .beans .factory .annotation .Value ;
6+ import org .springframework .cache .Cache ;
7+ import org .springframework .cache .caffeine .CaffeineCache ;
8+ import org .springframework .context .annotation .Bean ;
9+ import org .springframework .context .annotation .Configuration ;
10+ import org .springframework .security .oauth2 .jwt .JwtDecoder ;
11+ import org .springframework .security .oauth2 .jwt .NimbusJwtDecoder ;
12+
13+ @ Configuration
14+ public class JwtDecoderConfig {
15+
16+ @ Bean
17+ public JwtDecoder jwtDecoder (@ Value ("${aai.service-base-url}" ) String aaiBase ) {
18+
19+ com .github .benmanes .caffeine .cache .Cache <Object , Object > nativeCache =
20+ Caffeine .newBuilder ().expireAfterWrite (60 , TimeUnit .MINUTES ).maximumSize (100 ).build ();
21+
22+ Cache jwkCache = new CaffeineCache ("jwkCache" , nativeCache );
23+
24+ return NimbusJwtDecoder .withJwkSetUri (aaiBase + "/oidc/jwk" ).cache (jwkCache ).build ();
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments