java - 我可以在 Spring WebFlux 上实现 WebSecurityConfigurerAdapter

标签 java spring spring-boot spring-webflux

我目前正在使用 Springs 的 WebFlux,并且我想实现 Spring Security。我正在努力使我的任何 WebSecurityConfigurerAdapter http 规则发挥作用,我认为这是因为 HttpSecurity 更改没有效果。我将解释我的意思:

我选择实现具有方法签名的WebSecurityConfigurerAdapter

protected void configure(HttpSecurity http) throws Exception

这已正确配置,但我的所有端点都收到未经授权的401(这是典型的配置未被选取并使用默认配置的情况)。相反,当我查看 WebFluxSecurity 的实现时,他们通常会实现具有以下签名的 Bean:

public SecurityWebFilterChain securitygWebFilterChain(
  ServerHttpSecurity http)

我知道很多 WebFlux 架构实现了一组与典型 Spring 不同的请求和响应对象,所以我想知道我是否必须实现 WebFlux 安全处理方式,或者是否需要更多实现安全性的标准 WebSecurityConfigurerAdapter 方式应该仍然有效

干杯

最佳答案

WebFluxSecurity 使用 ServerHttpSecurity 使用 WebFilter 来过滤请求。 WebSecurity 使用 HttpSecurityjavax.servlet.Filter 来过滤请求。

这是不同的类和不同的实现,覆盖:

protected void configure(HttpSecurity http) throws Exception

不起作用

关于java - 我可以在 Spring WebFlux 上实现 WebSecurityConfigurerAdapter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51234311/

相关文章:

java - 如何在多个模块/项目中配置多个缓存管理器 spring cache java

java - 为什么需要用 BoxLayout 调用 setLayout?

java - 有什么方法可以搜索,然后从 String 中调用 java 中的方法?

java - 我得到一个 java.sql.sqlexception : Invalid column index error using a CallableStatement

java - Kafka 生产者发送无效字符

spring - 方面未运行 | Spring Boot

java - String javax.xml.xpath.XPathExpression.evaluate(Object item) 保证它在所有实现中永远不会返回 null?

java - Thymeleaf 返回 String 数组而不是 List<Object>

java - Autowiring ,不按类型装配 bean

java - PostgreSQL 和 hibernate 按版本号排序 1.1.1.1.1