我试图忽略身份验证中的 url 我尝试了多种不同的模式,但 java 似乎无法识别它们。我的配置如下所示:
@Override
public void configure(WebSecurity web) throws Exception {
super.configure(web);
web.ignoring().antMatchers(
"/api/pies.*active=true");
}
我想要匹配并让 spring security 忽略的字符串是这样的:
http://"someEnv"/"somePath"/api/pies?active=true
然而,无论我尝试什么通配符组合,它都不匹配。
匹配必须有 ?active=true
下面是方法定义:
@GetMapping()
public ResponseEntity<List<PieResponseDto>> getPies(@RequestParam(name = "active") Boolean active)
下面是类定义:
@RestController
@RequestMapping(path = "/api/pies", produces = MediaType.APPLICATION_JSON_VALUE)
Use .regexMatchers
代替.antMatchers
然后尝试这个正则表达式:
^[a-zA-Z:\/.]*pies\?active=true$
有很多用于正则表达式的在线工具。例如,您可以尝试这个:在线正则表达式测试器 https://regex101.com/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)