java - AuthenticationVoters 没有有效的属性。SpringSecurity
问题描述
我在 Spring Boot 2.1 上工作。
我希望允许我的所有默认端点
- 如果他们被正确认证
- 如果他们传递了我已经实现并命名为 * hashSerialSecurityVoter*的特定身份验证规则。
我的代码:
安全配置.java
protected void configure(HttpSecurity http) throws Exception {
http.csrf()
.disable().cors().and().exceptionHandling()
/* [...] */
.anyRequest()
.authenticated();
.accessDecisionManager(playerResourceDecisionManager());
}
@Bean
public AccessDecisionManager playerResourceDecisionManager() {
List<AccessDecisionVoter<? extends Object>> decisionVoters = Arrays.asList(
new AuthenticatedVoter(),
hashSerialSecurityVoter
);
return new UnanimousBased(decisionVoters);
}
它有效地通过两个选民。
但是在 AuthenticatedVoter 中,它并没有按我预期的那样运行。
即使我通过了身份验证,它也会返回ACCESS_ABSTAIN 值。
当我调试它时,我注意到 Manager 没有提供任何 ConfigAttribute。
所以authenticatedVoter.supports()
方法返回false..
我错过了 accessDecisionManager 声明中的某些内容吗?
结果是我的主要 API 客户端不再工作,因为我的所有请求都返回 403。
解决方案
推荐阅读
- python - python usb键盘拔掉
- mongodb - 使用 mongoexport 导出数据库时必须在 MongoDB 中指定一个集合
- c# - 是否可以使用 C# 修改像参数一样传递给其他线程的对象?
- arrays - 快速有效地获取基于其“值”的字典“键”,它是 Swift 中的字符串数组
- amazon-web-services - 如何调试或修复连接拒绝尝试卷曲 EC2 实例端口?
- r - 优化 R 中散点图生成的代码
- woocommerce - 使用 REST API 更新与产品 SKU 相关的 Woocommerce 产品图像链接
- excel - Excel 帮助:搜索第二次/第三次迭代以查找匹配状态
- java - 摇动设备时计步器活动刷新?
- react-native - 使用 SafeView 时无法更改状态栏背景颜色