首页 > 解决方案 > Spring WebSecurityConfig 有问题 antMatchers 访问有 IpAddress

问题描述

http.cors().and().csrf().disable();       
http.authorizeRequests().antMatchers("/api/**").access("hasIpAddress('Specific ip')"); 
http.formLogin().permitAll();
http.exceptionHandling() .accessDeniedPage("/denied"); 
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED);          
http.headers().frameOptions().disable();

在网络浏览器上测试时效果很好。某些 ip 限制是可能的,但在移动网络上,当通过 Wi-Fi 连接时,它运行良好,但当通过数据连接时,/api 无法正常运行。如何解决?

标签: javascriptspring-bootspring-security

解决方案


推荐阅读