我有以下 spring 安全配置片段:
http
.authorizeRequests()
.antMatchers("/tokens").hasIpAddress("10.0.0.0/16")
....
这可行,但我还想授予从 127.0.0.1
访问 "/tokens"
的权限。我希望按照以下方式进行操作,但它没有:
http
.authorizeRequests()
.antMatchers("/tokens").hasIpAddress("10.0.0.0/16").hasIpAddress("127.0.0.1/32")
....
最佳答案
http
.authorizeRequests()
.antMatchers("/tokens").access(
"hasIpAddress('10.0.0.0/16') or hasIpAddress('127.0.0.1/32')")
....
关于Spring 安全多个 hasIPAddress antMatchers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28303097/