Spring Security多个hasIPAddress antMatchers [英] Spring security multiple hasIPAddress antMatchers

查看:577
本文介绍了Spring Security多个hasIPAddress antMatchers的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下Spring安全配置代码段:

I have the following spring security configuration snippet:

http
   .authorizeRequests()
   .antMatchers("/tokens").hasIpAddress("10.0.0.0/16")
   ....

这可行,但是我也想授予从127.0.0.1"/tokens"的访问权限.我原本希望按照以下方式进行工作,但不能:

This works, but I would also like to grant access to "/tokens" from 127.0.0.1. I was hoping something along the lines of the following would work, but it doesn't:

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 Security多个hasIPAddress antMatchers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆