@Override
protected void configure(HttpSecurity http) throws Exception {
http
.antMatcher("/**")
.authorizeRequests()
.requestMatchers(new RequestHeaderRequestMatcher("Caller", "Rem"))
.hasAnyRole("USER")
.and()
.httpBasic();
}
我希望传入的请求包含在标头(“ Caller”,“ Rem”)中,它可以继续到端点。
发生的结果是相反的结果:这是我正在与邮递员尝试的请求:
http://本地主机:8092 / api / v1 /定价/安全性/配置/公共
如果我将(“ Caller”,“ Rem”)放在标头中,它将进入“ RequestHeaderRequestMatcher”的matchs函数,并发现它为TRUE,但未到达端点且返回401
] >如果我不输入(“ Caller”,“ Rem”),则将其放入“ RequestHeaderRequestMatcher”的matchs函数中,并发现它为FALSE,但它发生在端点并返回结果I想要。
我想要
@@ Override protected void configure(HttpSecurity http)引发异常{http .antMatcher(“ / **”).authorizeRequests().requestMatchers(new ...
由于当出现“ Caller”标头且值为“ Rem”时,您希望您的请求通过。您可以尝试这个。这会工作