小编Ant*_*Mor的帖子

Spring 5 + WebFlux安全性+ JWT令牌

在一个使用Spring Boot 2启动器+ Spring 5.0.7 + Reactor(WebFlux)的项目中,我们想使用Spring Security来实现安全性。仅包括入门者:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

和豆:

@Bean
SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) throws Exception {
    return http.authorizeExchange()
            .anyExchange().authenticated()
            .and().build();
    }
Run Code Online (Sandbox Code Playgroud)

绰绰有余。

但是,我们希望使用JWT令牌(由另一方在资源服务器中生成)来拦截这些Authorization标头。我一直在为此苦苦挣扎,但找不到Spring 5的任何示例(而对于Spring <5,有许多示例和教程)。

有人碰过这个问题吗?

spring-security jwt spring-boot project-reactor spring-webflux

6
推荐指数
1
解决办法
2310
查看次数