Spring Security 5.1.0.RC1 发布

发布 | Josh Cummings | 2018 年 8 月 21 日 | ...

我代表社区高兴地宣布 Spring Security 5.1.0.RC1 发布。此版本解决了 50+ 个问题

一如既往,我们期待听到您的反馈!您可以在下面找到亮点:

目录

Servlet

OAuth2 资源服务器

Open ID 提供者配置

资源服务器现在可以通过任何支持 Open Id Provider Configuration 的颁发者端点进行配置。

@Bean
JwtDecoder jwtDecoder() {
    return JwtDecoders.createDefaultFromIssuer("https://issuer-endpoint");
}

Claim 验证

用户可以通过暴露一个 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;
}

GrantedAuthority 提取

用户可以自定义如何从 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;
}

OAuth2 客户端凭证授权

已添加对 Client Credentials Grant Type 的基本支持

Feature-Policy 安全头

已添加对 Feature-Policy 的基本支持。

http
    .headers()
        .featurePolicy("geolocation 'none'");

WebFlux

OAuth2 资源服务器

已添加对基于响应式的 OAuth2 资源服务器的基本支持。请参阅 oauth2resourceserver-webflux

OAuth2 登录/客户端

授权码授权

已添加对基于响应式的授权码授权流程的基本支持。请参阅 authcodegrant-webflux

授权请求解析器

已添加对自定义发送给授权服务器的认证请求的支持。在授权服务器需要发送自定义参数时非常方便。在多租户场景下,请求中的主机名等元素可能会改变发送到授权服务器的请求方式,这时它也很有用。

已授权客户端存储库

已添加对自定义已授权客户端在请求之间的持久化存储的支持。

http
    .oauth2()
        .client()
            .authorizedClientRepository(new MyCookieBasedClientRepository());

强化您的应用

安全头

WebFlux 已添加对以下安全头的支持:

  • Content-Security-Policy

  • Referrer-Policy

  • Feature-Policy

CORS

Webflux 已添加对 CORS 的支持。

依赖更新

我们已经更新了依赖,以确保我们的传递性依赖是最新的。

项目网站 | 参考文档 | 帮助

订阅 Spring 快讯

通过 Spring 快讯保持联系

订阅

领先一步

VMware 提供培训和认证,助您加速进步。

了解更多

获取支持

Tanzu Spring 通过一个简单的订阅即可提供对 OpenJDK™、Spring 和 Apache Tomcat® 的支持和二进制文件。

了解更多

即将举行的活动

查看 Spring 社区中所有即将举行的活动。

查看全部