Get ahead
VMware offers training and certification to turbo-charge your progress.
Learn moreOn behalf of the community I am pleased to announce the release of Spring Security 5.1.0.RC1. This release comes with 50+ tickets closed.
As always we look forward to hearing your feedback! You can find the highlights below:
Resource Server is now configurable via any issuer endpoint that supports Open Id Provider Configuration:
@Bean
JwtDecoder jwtDecoder() {
return JwtDecoders.createDefaultFromIssuer("https://issuer-endpoint");
}
Users can add their own validation rules to apply to a Jwt
by exposing a JwtDecoder
bean:
@Bean
JwtDecoder jwtDecoder() {
String jwkSetUri = "https://issuer-endpoint/.well-known/jwks.json";
NimbusJwtDecoderJwkSupport jwtDecoder =
new NimbusJwkDecoderJwkSupport(jwkSetUri);
OAuth2TokenValidator<Jwt> validator =
new DelegatingOAuth2TokenValidator(
JwtValidators.createDefault(),
new MyCustomValidator());
jwtDecoder.setJwtValidator(validator);
return jwtDecoder;
}
Users can customize how GrantedAuthority
s are derived from a Jwt
:
@Bean
JwtDecoder jwtDecoder() {
String jwkSetUri = "https://issuer-endpoint/.well-known/jwks.json";
NimbusJwtDecoderJwkSupport jwtDecoder =
new NimbusJwkDecoderJwkSupport(jwkSetUri);
JwtAuthenticationConverter jwtAuthenticationConverter =
new JwtAuthenticationConverter() {
protected Collection<GrantedAuthority> extractAuthorities(Jwt jwt) {
return Arrays.asList(new SimpleGrantedAuthority("app:read"));
}
};
jwtDecoder.setJwtAuthenticationConverter(jwtAuthenticationConverter);
return jwtDecoder;
}
Basic Support for the Client Credentials Grant Type has been added.
Basic support for the Feature-Policy has been added:
http
.headers()
.featurePolicy("geolocation 'none'");
Basic support for Reactive-based OAuth2 Resource Servers has been added. See oauth2resourceserver-webflux
Basic support for Reactive-based Authorization Code Grant flow has been added. See authcodegrant-webflux
Support for customizing the authentication request made to the Authorization Server has been added. This is handy if, for example, the authorization server requires a custom parameter to be sent. It is also helpful in multi-tenant scenarios where elements of the request like the hostname may change how the request to an authorization server is made.
Support for customizing the persistence of authorized clients between requests has been added:
http
.oauth2()
.client()
.authorizedClientRepository(new MyCookieBasedClientRepository());
Support for the following secure headers has been added to WebFlux:
Content-Security-Policy
Referrer-Policy
Feature-Policy
Support for CORS has been added to Webflux.
We have updated our dependencies to be on the latest and greatest to ensure our transitive dependencies are up to date.