Java Spring Boot-多个ip地址的FilterRegistrationBean setAllow()
如何为2个或多个ip地址设置Java Spring Boot-多个ip地址的FilterRegistrationBean setAllow(),java,spring,spring-boot,spring-security,Java,Spring,Spring Boot,Spring Security,如何为2个或多个ip地址设置setAllow()(=授予对我的Web服务器的ip访问权限) 这对于一个地址来说是完美的: @Bean public FilterRegistrationBean remoteAddressFilter() { FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(); RemoteAddrFilter filter = new RemoteAdd
setAllow()
(=授予对我的Web服务器的ip访问权限)
这对于一个地址来说是完美的:
@Bean
public FilterRegistrationBean remoteAddressFilter() {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
RemoteAddrFilter filter = new RemoteAddrFilter();
filter.setAllow("127\\.0\\.0\\.1");
filter.setDenyStatus(403);
filterRegistrationBean.setFilter(filter);
filterRegistrationBean.addUrlPatterns("/*");
return filterRegistrationBean;
}
我正在考虑将一个白名单属性文件预加载到我的过滤器bean中,但在web上找不到合适的实现
我不使用任何.xml
文件进行配置。如果您的解决方案需要创建web.xml
,请详细说明如何创建、放在哪里以及如何调用
注意:新的Spring/Spring启动和安全配置设置
谢谢。只需通过
将它们分开即可,例如127\\.0\\.1 | 192\\.168\.0\.1
这只是一个普通的正则表达式值。只需通过
将它们分开即可,例如127\\\.0\.0\.1 | 192\\\.168\.0\\.1
这只是一个普通的正则表达式值。.matchers(“/hasIpAddress”(“hasIpAddress”)或(“hasIpAddress”)地址('xxx.xx.xx.x1'))或hasIpAddress('xxx.xx.x2')”
等等。在access
表达式中只需或或或|
。nope的可能重复不是重复,我的问题指向FilterRegistrationBeanantMatchers(“/”)。access(“hasIpAddress('127.0.0.1'))或hasIpAddress('xxx.xx.xx.x1'))或hasIpAddress('xxx.xx.xx.x2')”
等等。在access
表达式中只是或或或|
。nope的可能重复不是重复,我的问题指向FilterRegistrationBean