我有一个SpringBoot应用程序,希望检测正在调用的liveness端点,这样我就可以允许请求未经身份验证。
当我提出这个请求时:
http://localhost:8080/001/MyApp/actuator/health/liveness
下面的代码打印false
。
new AntPathRequestMatcher("/**liveness")
不应该导致isWhitelisted
返回true
吗?
public RequestMatcher getRequestMatcher() {
return new OrRequestMatcher(
new AntPathRequestMatcher("/error"),
new AntPathRequestMatcher("/login**"),
new AntPathRequestMatcher("/**logout"),
new AntPathRequestMatcher("/**liveness"));
}
public boolean isWhitelisted(HttpServletRequest httpServletRequest) {
return getRequestMatcher().matches(httpServletRequest);
}
System.out.println(requestPropertyResolver.isWhitelisted(httpServletRequest));
需要这个:
return new OrRequestMatcher(
new AntPathRequestMatcher("/error"),
new AntPathRequestMatcher("/login**"),
new AntPathRequestMatcher("/**logout"),
new AntPathRequestMatcher("/**/liveness"));
/**/
-匹配路径中的零个或多个"目录",因此需要结束目录树