领先一步
VMware 提供培训和认证,助您加速进步。
了解更多我谨代表社区,很高兴宣布 Spring Security 5.1.0.RC1 发布。此版本共关闭了 50+ 个 ticket。
一如既往,我们期待听到您的反馈!您可以在下方找到要点
资源服务器现在可以通过支持 Open Id Provider Configuration 的任何 issuer 端点进行配置
@Bean
JwtDecoder jwtDecoder() {
return JwtDecoders.createDefaultFromIssuer("https://issuer-endpoint");
}
用户可以通过公开 JwtDecoder bean 来添加自己的验证规则以应用于 Jwt
@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;
}
用户可以自定义如何从 Jwt 中派生 GrantedAuthority
@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;
}
已添加对 客户端凭证授权类型 的基本支持。
已添加对 Feature-Policy 的基本支持
http
.headers()
.featurePolicy("geolocation 'none'");
已添加对 Reactive-based OAuth2 资源服务器的基本支持。请参阅 oauth2resourceserver-webflux
已添加对 Reactive-based 授权码授权流程的基本支持。请参阅 authcodegrant-webflux
已添加对 定制向 Authorization Server 发出的认证请求的支持。如果您需要,例如,Authorization Server 要求发送自定义参数,这会非常有用。在多租户场景下,当请求的元素(如主机名)会影响向 Authorization Server 发送请求的方式时,这也会很有帮助。
已添加对自定义请求之间已授权客户端持久化的支持
http
.oauth2()
.client()
.authorizedClientRepository(new MyCookieBasedClientRepository());
已向 WebFlux 添加了对以下安全头的支持
Content-Security-Policy
Referrer-Policy
Feature-Policy
已向 Webflux 添加了对 CORS 的支持。
我们已将依赖项更新到最新版本,以确保我们的传递性依赖项是最新的。