@@ -217,12 +217,17 @@ More powerful than `jwkSetUri()` is `decoder()`, which will completely replace a
217
217
@Bean
218
218
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
219
219
http
220
- .authorizeExchange()
221
- .anyExchange().authenticated()
222
- .and()
223
- .oauth2ResourceServer()
224
- .jwt()
225
- .decoder(myCustomDecoder());
220
+ .authorizeExchange(exchanges ->
221
+ exchanges
222
+ .anyExchange().authenticated()
223
+ )
224
+ .oauth2ResourceServer(oauth2ResourceServer ->
225
+ oauth2ResourceServer
226
+ .jwt(jwt ->
227
+ jwt
228
+ .decoder(myCustomDecoder())
229
+ )
230
+ );
226
231
return http.build();
227
232
}
228
233
----
@@ -425,12 +430,17 @@ To this end, the DSL exposes `jwtAuthenticationConverter()`:
425
430
@Bean
426
431
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
427
432
http
428
- .authorizeExchange()
429
- .anyExchange().authenticated()
430
- .and()
431
- .oauth2ResourceServer()
432
- .jwt()
433
- .jwtAuthenticationConverter(grantedAuthoritiesExtractor());
433
+ .authorizeExchange(exchanges ->
434
+ exchanges
435
+ .anyExchange().authenticated()
436
+ )
437
+ .oauth2ResourceServer(oauth2ResourceServer ->
438
+ oauth2ResourceServer
439
+ .jwt(jwt ->
440
+ jwt
441
+ .jwtAuthenticationConverter(grantedAuthoritiesExtractor())
442
+ )
443
+ );
434
444
return http.build();
435
445
}
436
446
@@ -667,9 +677,10 @@ When use Opaque Token, this `SecurityWebFilterChain` looks like:
667
677
@Bean
668
678
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
669
679
http
670
- .authorizeExchange()
671
- .anyExchange().authenticated()
672
- .and()
680
+ .authorizeExchange(exchanges ->
681
+ exchanges
682
+ .anyExchange().authenticated()
683
+ )
673
684
.oauth2ResourceServer(ServerHttpSecurity.OAuth2ResourceServerSpec::opaqueToken)
674
685
return http.build();
675
686
}
@@ -686,13 +697,18 @@ public class MyCustomSecurityConfiguration {
686
697
@Bean
687
698
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
688
699
http
689
- .authorizeExchange()
690
- .pathMatchers("/messages/**").hasAuthority("SCOPE_message:read")
691
- .anyExchange().authenticated()
692
- .and()
693
- .oauth2ResourceServer()
694
- .opaqueToken()
695
- .introspector(myIntrospector());
700
+ .authorizeExchange(exchanges ->
701
+ exchanges
702
+ .pathMatchers("/messages/**").hasAuthority("SCOPE_message:read")
703
+ .anyExchange().authenticated()
704
+ )
705
+ .oauth2ResourceServer(oauth2ResourceServer ->
706
+ oauth2ResourceServer
707
+ .opaqueToken(opaqueToken ->
708
+ opaqueToken
709
+ .introspector(myIntrospector())
710
+ )
711
+ );
696
712
return http.build();
697
713
}
698
714
}
@@ -728,13 +744,18 @@ public class DirectlyConfiguredIntrospectionUri {
728
744
@Bean
729
745
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
730
746
http
731
- .authorizeExchange()
732
- .anyExchange().authenticated()
733
- .and()
734
- .oauth2ResourceServer()
735
- .opaqueToken()
736
- .introspectionUri("https://idp.example.com/introspect")
737
- .introspectionClientCredentials("client", "secret");
747
+ .authorizeExchange(exchanges ->
748
+ exchanges
749
+ .anyExchange().authenticated()
750
+ )
751
+ .oauth2ResourceServer(oauth2ResourceServer ->
752
+ oauth2ResourceServer
753
+ .opaqueToken(opaqueToken ->
754
+ opaqueToken
755
+ .introspectionUri("https://idp.example.com/introspect")
756
+ .introspectionClientCredentials("client", "secret")
757
+ )
758
+ );
738
759
return http.build();
739
760
}
740
761
}
@@ -754,12 +775,17 @@ public class DirectlyConfiguredIntrospector {
754
775
@Bean
755
776
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
756
777
http
757
- .authorizeExchange()
758
- .anyExchange().authenticated()
759
- .and()
760
- .oauth2ResourceServer()
761
- .opaqueToken()
762
- .introspector(myCustomIntrospector());
778
+ .authorizeExchange(exchanges ->
779
+ exchanges
780
+ .anyExchange().authenticated()
781
+ )
782
+ .oauth2ResourceServer(oauth2ResourceServer ->
783
+ oauth2ResourceServer
784
+ .opaqueToken(opaqueToken ->
785
+ opaqueToken
786
+ .introspector(myCustomIntrospector())
787
+ )
788
+ );
763
789
return http.build();
764
790
}
765
791
}
0 commit comments