mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-25 21:42:17 +00:00
Updates OAuth2ResourceServer configuration tests
Refactores collapsed imports
This commit is contained in:
parent
7cfb17a8a3
commit
b6e8997e95
@ -27,7 +27,6 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Base64;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@ -1500,12 +1499,11 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
}
|
||||
|
||||
Converter<Jwt, AbstractAuthenticationToken> getJwtAuthenticationConverter() {
|
||||
return new JwtAuthenticationConverter() {
|
||||
@Override
|
||||
protected Collection<GrantedAuthority> extractAuthorities(Jwt jwt) {
|
||||
return Collections.singletonList(new SimpleGrantedAuthority("message:read"));
|
||||
}
|
||||
};
|
||||
JwtAuthenticationConverter converter = new JwtAuthenticationConverter();
|
||||
converter.setJwtGrantedAuthoritiesConverter(jwt ->
|
||||
Collections.singletonList(new SimpleGrantedAuthority("message:read"))
|
||||
);
|
||||
return converter;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@ import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.RSAPublicKeySpec;
|
||||
import java.time.Instant;
|
||||
import java.util.Base64;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
@ -56,7 +55,6 @@ import org.springframework.security.authentication.ReactiveAuthenticationManager
|
||||
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
|
||||
import org.springframework.security.config.test.SpringTestRule;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
||||
import org.springframework.security.oauth2.core.OAuth2Error;
|
||||
@ -556,13 +554,12 @@ public class OAuth2ResourceServerSpecTests {
|
||||
|
||||
@Bean
|
||||
Converter<Jwt, Mono<AbstractAuthenticationToken>> jwtAuthenticationConverter() {
|
||||
JwtAuthenticationConverter converter = new JwtAuthenticationConverter() {
|
||||
@Override
|
||||
protected Collection<GrantedAuthority> extractAuthorities(Jwt jwt) {
|
||||
|
||||
JwtAuthenticationConverter converter = new JwtAuthenticationConverter();
|
||||
converter.setJwtGrantedAuthoritiesConverter(jwt -> {
|
||||
String[] claims = ((String) jwt.getClaims().get("scope")).split(" ");
|
||||
return Stream.of(claims).map(SimpleGrantedAuthority::new).collect(Collectors.toList());
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
return new ReactiveJwtAuthenticationConverterAdapter(converter);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user