Spring Security 5.1.0.RC1 发布

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

我谨代表社区,很高兴宣布 Spring Security 5.1.0.RC1 发布。此版本共关闭了 50+ 个 ticket

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

目录

Servlet

OAuth2 资源服务器

Open ID 提供商配置

资源服务器现在可以通过支持 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;
}

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 客户端凭证授权

已添加对 客户端凭证授权类型 的基本支持。

Feature-Policy 安全头

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

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

WebFlux

OAuth2 资源服务器

已添加对 Reactive-based OAuth2 资源服务器的基本支持。请参阅 oauth2resourceserver-webflux

OAuth2 登录/客户端

授权码授权

已添加对 Reactive-based 授权码授权流程的基本支持。请参阅 authcodegrant-webflux

授权请求解析器

已添加对 定制向 Authorization Server 发出的认证请求的支持。如果您需要,例如,Authorization Server 要求发送自定义参数,这会非常有用。在多租户场景下,当请求的元素(如主机名)会影响向 Authorization Server 发送请求的方式时,这也会很有帮助。

已授权客户端存储库

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

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 社区所有即将举行的活动。

查看所有