File tree 2 files changed +9
-14
lines changed
config/src/test/java/org/springframework/security/config
annotation/web/configurers/oauth2/server/resource
2 files changed +9
-14
lines changed Original file line number Diff line number Diff line change 27
27
import java .time .Instant ;
28
28
import java .time .ZoneId ;
29
29
import java .util .Base64 ;
30
- import java .util .Collection ;
31
30
import java .util .Collections ;
32
31
import java .util .Map ;
33
32
import java .util .stream .Collectors ;
@@ -1484,12 +1483,11 @@ protected void configure(HttpSecurity http) throws Exception {
1484
1483
}
1485
1484
1486
1485
Converter <Jwt , AbstractAuthenticationToken > getJwtAuthenticationConverter () {
1487
- return new JwtAuthenticationConverter () {
1488
- @ Override
1489
- protected Collection <GrantedAuthority > extractAuthorities (Jwt jwt ) {
1490
- return Collections .singletonList (new SimpleGrantedAuthority ("message:read" ));
1491
- }
1492
- };
1486
+ JwtAuthenticationConverter converter = new JwtAuthenticationConverter ();
1487
+ converter .setJwtGrantedAuthoritiesConverter (jwt ->
1488
+ Collections .singletonList (new SimpleGrantedAuthority ("message:read" ))
1489
+ );
1490
+ return converter ;
1493
1491
}
1494
1492
}
1495
1493
Original file line number Diff line number Diff line change 25
25
import java .security .spec .RSAPublicKeySpec ;
26
26
import java .time .Instant ;
27
27
import java .util .Base64 ;
28
- import java .util .Collection ;
29
28
import java .util .Collections ;
30
29
import java .util .Optional ;
31
30
import java .util .stream .Collectors ;
56
55
import org .springframework .security .config .annotation .web .reactive .EnableWebFluxSecurity ;
57
56
import org .springframework .security .config .test .SpringTestRule ;
58
57
import org .springframework .security .core .Authentication ;
59
- import org .springframework .security .core .GrantedAuthority ;
60
58
import org .springframework .security .core .authority .SimpleGrantedAuthority ;
61
59
import org .springframework .security .oauth2 .core .OAuth2AuthenticationException ;
62
60
import org .springframework .security .oauth2 .core .OAuth2Error ;
@@ -556,13 +554,12 @@ SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception
556
554
557
555
@ Bean
558
556
Converter <Jwt , Mono <AbstractAuthenticationToken >> jwtAuthenticationConverter () {
559
- JwtAuthenticationConverter converter = new JwtAuthenticationConverter () {
560
- @ Override
561
- protected Collection < GrantedAuthority > extractAuthorities ( Jwt jwt ) {
557
+
558
+ JwtAuthenticationConverter converter = new JwtAuthenticationConverter ();
559
+ converter . setJwtGrantedAuthoritiesConverter ( jwt -> {
562
560
String [] claims = ((String ) jwt .getClaims ().get ("scope" )).split (" " );
563
561
return Stream .of (claims ).map (SimpleGrantedAuthority ::new ).collect (Collectors .toList ());
564
- }
565
- };
562
+ });
566
563
567
564
return new ReactiveJwtAuthenticationConverterAdapter (converter );
568
565
}
You can’t perform that action at this time.
0 commit comments