繁体   English   中英

Spring Security中的IP身份验证

[英]Ip authentication in Spring Security

我的Web应用程序中装有Spring Security 4.2.2,并配置了基于LDAP的身份验证。 另外,我还需要使用指定的ip身份验证所有用户,而无需登录表单,并为他们设置“ local_user”角色。 如何执行该身份验证方案?

upd:我的意思是,“本地用户”必须查看与通过登录表单授权的用户相同的内容。

您可以使用antMatchers这样的代码,例如:

    @EnableWebSecurity
    @Configuration
    public class BasicSecurityConfig extends WebSecurityConfigurerAdapter{

    @Override
    protected void configure(HttpSecurity http) throws Exception {
         http.authorizeRequests().antMatchers("/baseUrl/anything-else/**").hasIpAddress("ipAddressExpression")
    }
}

更新

http.authorizeRequests()
        .antMatchers("/baseUrl/anything-else/**").access("hasIpAddress('ipAddressExpression') or fullyAuthenticated()");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM