File tree Expand file tree Collapse file tree 2 files changed +9
-14
lines changed
config/src/test/java/org/springframework/security/config
annotation/web/configurers/oauth2/server/resource Expand file tree Collapse file tree 2 files changed +9
-14
lines changed Original file line number Diff line number Diff line change 2727import java .time .Instant ;
2828import java .time .ZoneId ;
2929import java .util .Base64 ;
30- import java .util .Collection ;
3130import java .util .Collections ;
3231import java .util .Map ;
3332import java .util .stream .Collectors ;
@@ -1484,12 +1483,11 @@ protected void configure(HttpSecurity http) throws Exception {
14841483 }
14851484
14861485 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 ;
14931491 }
14941492 }
14951493
Original file line number Diff line number Diff line change 2525import java .security .spec .RSAPublicKeySpec ;
2626import java .time .Instant ;
2727import java .util .Base64 ;
28- import java .util .Collection ;
2928import java .util .Collections ;
3029import java .util .Optional ;
3130import java .util .stream .Collectors ;
5655import org .springframework .security .config .annotation .web .reactive .EnableWebFluxSecurity ;
5756import org .springframework .security .config .test .SpringTestRule ;
5857import org .springframework .security .core .Authentication ;
59- import org .springframework .security .core .GrantedAuthority ;
6058import org .springframework .security .core .authority .SimpleGrantedAuthority ;
6159import org .springframework .security .oauth2 .core .OAuth2AuthenticationException ;
6260import org .springframework .security .oauth2 .core .OAuth2Error ;
@@ -556,13 +554,12 @@ SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception
556554
557555 @ Bean
558556 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 -> {
562560 String [] claims = ((String ) jwt .getClaims ().get ("scope" )).split (" " );
563561 return Stream .of (claims ).map (SimpleGrantedAuthority ::new ).collect (Collectors .toList ());
564- }
565- };
562+ });
566563
567564 return new ReactiveJwtAuthenticationConverterAdapter (converter );
568565 }
You can’t perform that action at this time.
0 commit comments