Spring Security 5.0.0 M4 发布

发布 | Rob Winch | 2017 年 9 月 15 日 | ...

我很高兴代表社区宣布 Spring Security 5.0.0 M4 发布。此版本包含错误修复、新功能,并基于 Spring Framework 5.0.0 RC4。您可以在变更日志中找到完整的详细信息。此版本的亮点包括

OAuth2 / OIDC

OAuth2 登录 Java 配置

HttpSecurity.oauth2Login() DSL 进行了一些改进。

您现在可以使用 AuthorizationGrantTokenExchangerSecurityTokenRepository<AccessToken> 的自定义实现来配置 Token 端点,如下所示

protected void configure(HttpSecurity http) throws Exception {
  http
    .authorizeRequests()
      .anyRequest().authenticated()
      .and()
    .oauth2Login()
      .tokenEndpoint()
        .authorizationCodeTokenExchanger(this.authorizationCodeTokenExchanger())
	.accessTokenRepository(this.accessTokenRepository());
}

我们还增加了自定义 Authorization 端点Redirection 端点的请求路径的功能

protected void configure(HttpSecurity http) throws Exception {
  http
    .authorizeRequests()
      .anyRequest().authenticated()
      .and()
    .oauth2Login()
      .authorizationEndpoint()
        .requestMatcher(new AntPathRequestMatcher("/custom-path/{clientAlias}"))
        .and()
      .redirectionEndpoint()
        .requestMatcher(new AntPathRequestMatcher("/custom-path/callback/{clientAlias}"));
}

与 Spring Security 中的所有 AbstractAuthenticationProcessingFilter 一样,您还可以设置自定义的 AuthenticationSuccessHandlerAuthenticationFailureHandler

protected void configure(HttpSecurity http) throws Exception {
  http
    .authorizeRequests()
      .anyRequest().authenticated()
      .and()
     .oauth2Login()
       .successHandler(this.customAuthenticationSuccessHandler())
       .failureHandler(this.customAuthenticationFailureHandler());
}

安全令牌存储库

我们引入了 SecurityTokenRepository<T extends SecurityToken> 抽象,它负责 SecurityToken 的持久化。

最初的实现 InMemoryAccessTokenRepository 提供了 AccessToken 的持久化。在即将发布的版本中,我们还将提供一个支持 Refresh Token 持久化的实现。

ID 令牌和声明

IdToken 进行了一些小的改进,同时完善了 JwtClaimAccessorStandardClaimAccessorIdTokenClaimAccessor 的实现细节,这些类提供了方便访问其关联结构中 claims 的方式,例如 JwtIdTokenUserInfo

授权请求改进

我们增加了 AuthorizationRequestRepositoryAuthorization Request 持久化到 Cookie 的功能。当前的默认实现是持久化到 HttpSession 中,但是可以提供一个自定义实现来代替持久化到 Cookie

还增加了对 AuthorizationCodeRequestRedirectFilter 中配置的 redirect-uri 中的 URI 变量的支持。

OAuth2 客户端属性

对配置 OAuth 2.0 Client 的属性进行了一些小的更新。以下配置概述了当前结构。您会注意到支持配置多个客户端,例如 google、github、okta 等。

security:
  oauth2:
    client:
      google:
        client-id: your-app-client-id
        client-secret: your-app-client-secret
        client-authentication-method: basic
        authorization-grant-type: authorization_code
        redirect-uri: "{scheme}://{serverName}:{serverPort}{contextPath}/oauth2/authorize/code/{clientAlias}"
        scope: openid, profile, email, address, phone
        authorization-uri: "https://#/o/oauth2/v2/auth"
        token-uri: "https://www.googleapis.com/oauth2/v4/token"
        user-info-uri: "https://www.googleapis.com/oauth2/v3/userinfo"
        user-name-attribute-name: "sub"
        jwk-set-uri: "https://www.googleapis.com/oauth2/v3/certs"
        client-name: Google
        client-alias: google
      github:
        ...
      okta:
        ...

使用新的 Spring Security OAuth 2.0 / OpenID Connect 1.0 登录功能的完整示例可以在 Spring Security 示例中的 oauth2login 中找到。该指南将引导您完成使用外部 OAuth 2.0 或 OpenID Connect 1.0 Provider 设置示例应用程序以进行 OAuth 2.0 登录的步骤。

响应式安全

响应式方法安全

Spring Security 的响应式支持现在通过利用 Reactor 的 Context 包含了方法安全。亮点如下,您可以在 samples/javaconfig/hellowebflux-method 中找到它的完整示例

第一步是使用 @EnableReactiveMethodSecurity 启用对 @PreAuthorize@PostAuthorize 注解的支持。此步骤确保对象得到正确代理。

@EnableWebFluxSecurity
@EnableReactiveMethodSecurity
public class SecurityConfig {

下一步是创建一个使用 @PreAuthorize@PostAuthorize 注解的服务。例如

@PreAuthorize("hasRole('ADMIN')")
public Mono<String> findMessage() {

Spring Security 的 WebFlux 支持将确保 Reactor Context 会填充当前用户,该用户用于确定是否授予或拒绝访问。

Spring Security 的标准 @WithMockUser相关注解已更新,可与响应式方法安全一起使用。例如

@RunWith(SpringRunner.class)
// ...
public class HelloWorldMessageServiceTests {
  @Autowired
  HelloWorldMessageService messages;

@Test public void messagesWhenNotAuthenticatedThenDenied() { StepVerifier.create(this.messages.findMessage()) .expectError(AccessDeniedException.class) .verify(); }

@Test @WithMockUser public void messagesWhenUserThenDenied() { StepVerifier.create(this.messages.findMessage()) .expectError(AccessDeniedException.class) .verify(); }

@Test @WithMockUser(roles = "ADMIN") public void messagesWhenAdminThenOk() { StepVerifier.create(this.messages.findMessage()) .expectNext("Hello World!") .verifyComplete(); } }

测试支持也与 TestWebClient 良好配合。例如

@RunWith(SpringRunner.class)
// ...
public class HelloWebfluxMethodApplicationTests {
  @Autowired
  ApplicationContext context;

WebTestClient rest;

@Before public void setup() { this.rest…

Spring Session MongoDB 2.0.0.M3 发布

工程 | Greg L. Turnquist | 2017 年 9 月 15 日 | ...

尊敬的 Spring 社区,

Spring Session MongoDB 2.0.0.M3 已发布。它基于

在此版本中,添加了一些新功能,以简化在 Spring WebFlux 应用程序中使用它。

@EnableMongoWebSession
public class SpringWebFluxConfig {

}

您只需将 @EnableMongoWebSession 应用于您的任何 Spring 配置类,即可激活与 MongoDB 的会话支持。此外,您必须提供一个 ReactorMongoOperations Spring bean,但如果您正在使用 Spring Boot 的 spring-boot-starter-data-mongodb-reactive

Spring Session 2.0.0 M4

发布 | Rob Winch | 2017 年 9 月 15 日 | ...

我很高兴代表社区宣布 Spring Session 2.0.0.M4 发布。此版本主要专注于完善 WebFlux 支持。亮点包括

简化的 WebFlux 配置

为 WebFlux 配置 Spring Session 得到简化,只需

@Configuration
@EnableSpringWebSession
public class HelloWebfluxSessionConfig {

  @Bean
  public MapReactorSessionRepository reactorSessionRepository() {
    return new MapReactorSessionRepository(new ConcurrentHashMap<>());
  }
}

您还可以通过简单地添加一个 WebSessionIdResolver Bean 来切换解析会话 ID 的策略。例如,要将使用 cookie 解析会话 ID 切换到使用 header,您可以使用 Spring Framework 的新 HeaderWebSessionIdResolver

Spring Boot 2.0.0 M4 现已发布

发布 | Stéphane Nicoll | 2017 年 9 月 15 日 | ...

紧随最新的 Spring Framework 5 发布候选版本之后,Spring Boot 2.0 M4 现已从我们的里程碑存储库中提供。此版本关闭了 150 个问题和拉取请求,是迈向 2.0 GA 的重要一步。感谢所有做出贡献的人!

这个里程碑版本提供了一系列小的调整和增强,以及三个主要变化

有关更改的完整列表和升级说明,请参阅 WIKI 上的 Spring Boot 2.0.0.M4 发布说明。我们在更新参考文档方面有点落后,因此请考虑使用 快照版本

Spring Cloud Stream Ditmars/1.3 发布候选版本公告

发布 | Gary Russell | 2017 年 9 月 14 日 | ...

我们很高兴宣布 Spring Cloud Stream Ditmars.RC1 发布候选版本现已在 Spring Milestone 存储库中提供使用。发布说明包含与 Spring Boot、Spring Cloud、Spring AMQP 和 Spring for Apache Kafka 版本兼容性的相关信息。

Apache Kafka 的 Kafka Streams

此版本旨在将 Apache Kafka 的 Kafka Streams 支持提升为 Apache Kafka 绑定器实现中的顶级项目。将 Apache Kafka 的 Kafka Streams 定位为一流公民后,开发人员现在可以通过以下方式构建 Spring Cloud Stream 应用程序…

Spring Integration 5.0 Milestone 7 和 4.3.12 现已提供

发布 | Artem Bilan | 2017 年 9 月 14 日 | ...

我很高兴代表 Spring Integration 团队宣布 Spring Integration 5.0 版本的 Milestone 7 (5.0.0.M7) 现已提供。

可以从里程碑存储库下载

repositories {
    maven { url 'http://repo.spring.io/libs-milestone' }
}
compile "org.springframework.integration:spring-integration-core:5.0.0.M7"

此版本包含了 21 个 JIRA(以及一些 GitHub 问题),包括错误修复和一些新功能。自上次宣布的 Milestone 6 以来,M7 的一些功能亮点如下

  • Reactive WebFlux Channel Adapters 已提取到单独的 spring-integration-webflux 模块中,以区分基于 Servlet 的 MVC 配置与 Reactive 基础。

  • 引入了 EmbeddedJsonHeadersMessageMapper,以便将消息头部与有效载荷一起嵌入到针对不原生支持头部的目标协议(例如 TCP/IP、MQTT、AWS Kinesis 和 0.11.x 版本之前的 Apache Kafka)的包中。

  • java.util.function.Supplier 现在可以充当 MessageSource

Spring AMQP 2.0 发布候选版本、1.7.4 和 1.6.11 现已提供

发布 | Gary Russell | 2017 年 9 月 12 日 | ...

我很高兴宣布 Spring AMQP 的 2.0.0.RC1 发布候选版本现已在 Spring 里程碑存储库中提供。

自最终里程碑版本 Milestone 5 以来,此版本增加了一些小的修复/改进。

感谢所有社区成员的反馈和贡献!

GA 版本将在 9 月 Spring Framework 5.0 GA 版本发布后不久发布。

有关 2.0 中更改的完整列表,请参阅参考手册中的新功能

维护版本 1.7.41.6.11 也已提供。

项目页面 | JIRA | 贡献 | 帮助 | 聊天

Spring For Apache Kafka 2.0 和 1.3 发布候选版本现已提供

发布 | Gary Russell | 2017 年 9 月 12 日 | ...

我们很高兴宣布 Spring for Apache Kafka 2.0 版本的 2.0.0.RC1 发布候选版本现已提供。

正如在1.3.0.M2 公告中讨论的,我们正在与 2.0 同时发布 1.3 版本,其中 1.3 包含 2.0 功能的子集,支持 Kafka 0.11.x.x 客户端,同时仍然支持 Spring Framework 4.3。因此,1.3.0.RC1 发布候选版本也已提供。

可以从里程碑存储库下载

repositories {
    maven { url 'http://repo.spring.io/libs-milestone' }
}
compile "org.springframework.kafka:spring-kafka:2.0.0.RC1"

上次公告以来,以下是摘要…

Spring Boot 1.5.7 现已提供

发布 | Brian Clozel | 2017 年 9 月 12 日 | ...

我很高兴代表团队宣布 Spring Boot 1.5.7 已发布,现已从 repo.spring.ioMaven Central 提供。

Spring Boot 1.5.7 包括 51 个修复、改进和依赖更新。感谢所有通过问题报告和拉取请求做出贡献的人。

接下来是什么?

Spring Framework 5.0 RC4 刚刚发布,其他 Spring 项目也应该会跟进。Spring Boot 2.0 M4 即将到来,这将是测试 Spring Framework GA 之前的最后一个发布候选版本 的好方法。如果您想提前了解 Spring Boot 2,并且如果您这样做了,我们很乐意听取您的反馈,请访问 start.spring.io 并选择 Spring Boot 2.0.0.BUILD-SNAPSHOT

获取 Spring 时事通讯

通过 Spring 时事通讯保持联系

订阅

领先一步

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

了解更多

获取支持

Tanzu Spring 在一个简单的订阅中提供 OpenJDK™、Spring 和 Apache Tomcat® 的支持和二进制文件。

了解更多

即将举行的活动

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

查看全部