Spring security multiple hasIPAddress antMatchers

Spring security multiple hasIPAddress antMatchers

我有以下 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")
   ....

尝试在 spring 安全配置文件中这样设置此配置

<http auto-config="true" use-expressions="true">
<intercept-url pattern="/tokens**" access="hasIpAddress('10.0.0.0/16') or hasIpAddress('127.0.0.1/32')" />
</http>
http
    .authorizeRequests()
    .antMatchers("/tokens").access(
            "hasIpAddress('10.0.0.0/16') or hasIpAddress('127.0.0.1/32')")
....