关于 spring security 配置问题
資深大佬 : monkeyWie 0
想实现只对 /actuator/** 路径会进行鉴权,并且在源 ip 为内网的时候放行,否则需要通过 HTTP basic 认证
目前的配置可以实现内网放行,代码如下:
http.antMatcher("/actuator/**") .authorizeRequests() .anyRequest() .access("hasIpAddress('::1')" + " or hasIpAddress('127.0.0.1')" + " or hasIpAddress('10.0.0.0/8')" + " or hasIpAddress('172.16.0.0/12')" + " or hasIpAddress('192.168.0.0/16')") .and() .httpBasic();
但是这样的话会导致配置文件中定义的用户名和密码失效:
spring.security.user.name=admin spring.security.user.password=123456
之前不做 ip 白名单的时候配置的用户密码可以生效的:
http.antMatcher("/actuator/**").authorizeRequests() .anyRequest().authenticated() .and() .httpBasic();
大佬们帮忙看看应该怎么配置,或者有没有什么最简单的办法能做自定义的权限校验。
大佬有話說 (1)