【发布时间】:2021-09-17 09:35:50
【问题描述】:
我有一个与 OAuth2AuthenticationProcessingFilter 相关的问题,我的应用程序需要来自 Microsoft Teams 机器人框架 (/api/messages) 的传入消息。
看起来好像消息被过滤了,因为它包含一个无效的令牌,但是这个端点应该是公共的,因为它是在配置中设置的 (noSecurityAllowedUrlPatterns 包含端点):
http.requestMatchers()
.and()
.authorizeRequests()
.antMatchers(noSecurityAllowedUrlPatterns.toArray(new String[0]))
.permitAll()
.anyRequest()
.authenticated();
这是过滤器中引发异常的行:
Authentication authResult = this.authenticationManager.authenticate(authentication);
这是端点:
@PostMapping({"/messages"})
@PreAuthorize("permitAll()")
public CompletableFuture<ResponseEntity<Object>> incoming(
@RequestBody Activity activity,
@RequestHeader(value = "Authorization", defaultValue = "") String authHeader) {
...
}
如何成功设置配置以避免此端点中的 oauth,或者如何将传入令牌添加到有效的一个列表中(以某种方式)? 过滤器列表顺序可能有问题,但是
【问题讨论】:
标签: spring-security oauth-2.0 botframework