Browse Source

鉴权获取ip修改

develop
lau572 8 months ago
parent
commit
1c1000465e
  1. 2
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

2
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@ -69,7 +69,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override @Override
public boolean matches(HttpServletRequest request) { public boolean matches(HttpServletRequest request) {
// 获取请求的IP // 获取请求的IP
String requestIP = request.getRemoteAddr(); String requestIP = request.getHeader("X-Forwarded-For");
// 将配置文件中的IP字符串分割为数组 // 将配置文件中的IP字符串分割为数组
String[] ips = allowedIPs.split(","); String[] ips = allowedIPs.split(",");
// 检查请求的IP是否在允许的IP数组中 // 检查请求的IP是否在允许的IP数组中

Loading…
Cancel
Save