我的应用程序使用 Spring Security。我知道您可以使用 antMatchers 来允许对映射到您的应用程序中的某些 URI 的请求。但我也需要允许从外部 api 向我的应用程序中的 URI 发出的请求,并且仅针对该 api。我需要这样的东西:
@Override
protected void configure(WebSecurity web) throws Exception
{
web.ignoring()
.antMatchers("http://externalTestApi.com");
}
有人知道这是否可行吗?我没有找到任何相关内容。
最佳答案
你可以这样做(如果你想组合多个条件)
.authorizeRequests()
.antMatchers("/user/list")
.access("authenticated or hasIpAddress('666.666.666.666') or hasIpAddress('127.0.0.1') or hasIpAddress('0:0:0:0:0:0:0:1')")
或
.authorizeRequests()
.antMatchers("/user/list")
.hasIpAddress("0.0.0.0/0");
关于java - Spring Security 禁用从某个 url 发出的请求的安全性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46564580/