简体   繁体   English

Spring OAuth2 授权服务器 + Spring WebFlux

[英]Spring OAuth2 Authorization Server + Spring WebFlux

I'm trying to rewrite existing OAuth2 authorization service using Spring Boot 3.0.2 and newly released Spring OAuth2 Authorization Server 1.0.0 .我正在尝试使用Spring Boot 3.0.2和新发布Spring OAuth2 Authorization Server 1.0.0重写现有的 OAuth2 授权服务。 Faced a trouble combing objects from Reactive Security and Standard Security libraries: unable to apply default security to OAuth2AuthorizationServerConfiguration class, because it's not applicable to reactive ServerHttpSecurity .面临从 Reactive Security 和 Standard Security 库组合对象的问题:无法将默认安全应用于OAuth2AuthorizationServerConfiguration class,因为它不适用于 Reactive ServerHttpSecurity

Code part代码部分

@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public SecurityWebFilterChain authServerSecurityFilterChain(ServerHttpSecurity http) throws Exception {
    OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http);
    http
        .formLogin()
        ...;

    return http.build();
}

Can't pass HttpSecurity to applyDefaultSecurity() method.无法将HttpSecurity传递给applyDefaultSecurity()方法。 Tried to find any reactive implementations of OAuth2AuthorizationServerConfiguration class but found nothing.试图找到OAuth2AuthorizationServerConfiguration class 的任何反应性实现,但一无所获。

Is there any way to convert ServerHttpSecurity to HttpSecurity ?有没有办法将ServerHttpSecurity转换为HttpSecurity Or Spring OAuth2 Authorization Server is completely incompatible with reactive approach?或者 Spring OAuth2 授权服务器与反应式方法完全不兼容?

Main dependencies of Maven pom.xml Maven pom.xml 的主要依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-oauth2-authorization-server</artifactId>
    <version>1.0.0</version>
</dependency>

Thanks is advance.谢谢是提前。

UPD更新程序

Searched badly.搜索不好。 Seems like it's not supported yet:好像还不支持:

https://github.com/spring-projects/spring-authorization-server/issues/152 https://github.com/spring-projects/spring-authorization-server/issues/152

Or there are still some ways make it work?或者还有一些方法可以让它发挥作用?

Official answer:官方回答:

We are strictly focusing on a Servlet implementation for the initial set of features that would qualify for a MVP version.我们严格关注符合 MVP 版本的初始功能集的 Servlet 实现。 We haven't decided whether we'll provide a WebFlux version at this point.我们还没有决定此时是否提供 WebFlux 版本。

Quite honestly, I'm not convinced it's needed.老实说,我不认为有必要。 The client and resource server(s) are the most active, whereas, the authorization server is not as active as it simply issues a token and may validate a token, which is limited activity between the many interactions that follow between a client and resource server after a token is issued.客户端和资源服务器是最活跃的,而授权服务器并不那么活跃,因为它只是发布令牌并可能验证令牌,这是客户端和资源服务器之间随后进行的许多交互之间的有限活动发行令牌后。

Either way, I'm going to close this issue as WebFlux is not on the roadmap as of now.无论哪种方式,我都将关闭这个问题,因为 WebFlux 目前不在路线图上。

Source - https://github.com/spring-projects/spring-authorization-server/issues/152来源 - https://github.com/spring-projects/spring-authorization-server/issues/152

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM