【问题标题】:Spring Active Directory Authentication using "proxy" user使用“代理”用户的 Spring Active Directory 身份验证
【发布时间】:2016-04-26 16:15:35
【问题描述】:

我的项目中有一个特殊要求,即针对 Active Directory 的身份验证应使用特殊(“代理”)用户完成。也就是说,首先我们必须使用这个特殊用户登录到 AD,然后我们应该“查询”AD 关于“真实”用户(尝试登录我的应用程序的用户)的凭据是否正确,使用“代理”用户会话。

有没有办法使用弹簧安全性来做到这一点? ...现在我正在使用org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider

这些是我当前的依赖项:

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>3.2.5.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>3.2.5.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>3.2.5.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-ldap</artifactId>
        <version>3.2.5.RELEASE</version>
    </dependency>

这是通过spring的身份验证部分的配置:

<beans:bean id="ldapAuthProvider" class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
    <beans:constructor-arg>
        <beans:value>${security.ad.domain}</beans:value>
    </beans:constructor-arg>
    <beans:constructor-arg>
        <beans:value>${security.ad.url}</beans:value>
    </beans:constructor-arg>
</beans:bean>

<authentication-manager>
    <authentication-provider ref="ldapAuthProvider" />
</authentication-manager>

感谢您的帮助!!

【问题讨论】:

    标签: java spring spring-security-ldap


    【解决方案1】:

    我成功地尝试了您的方案。也许晚了,但它可能会帮助别人。 首先,我按照here 的描述设置我的项目。 其次,我在WebSecurityConfig 类中添加了以下内容:

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception 
    {
        auth
            .ldapAuthentication()
                // User Base DN
                .userDnPatterns("cn={0},ou=...,ou=...,o=...,c=...") 
                .contextSource()
                    // ldap server
                    .url("ldaps://server:636") 
                    // Bind credentials Bind DN
                    .managerDn("cn=...,ou=...,o=...,c=...") 
                    // Bind credentials Bind Password
                    .managerPassword("...");
    }
    

    【讨论】:

      猜你喜欢
      • 2015-04-17
      • 1970-01-01
      • 2011-01-22
      • 1970-01-01
      • 1970-01-01
      • 2015-02-20
      • 2021-09-11
      • 1970-01-01
      • 2017-10-09
      相关资源
      最近更新 更多