ldap spring security http basic auth

时间:2013-01-27 19:57:25

标签: spring-security ldap http-basic-authentication

您能否给我一些管理问题的链接或解决方案? 问题如下。我有一个LDAP服务器。如何通过此LDAP服务器进行http基本授权?

提前致谢。

2 个答案:

答案 0 :(得分:1)

您需要设置Spring Security的两个不同功能:

答案 1 :(得分:0)

感谢。我做了这样的配置:

<security:http auto-config="true" use-expressions="true">
    <security:intercept-url pattern="/index.jsp" access="isAuthenticated()"/>
    <security:http-basic/>
</security:http>

然后,BasicAuthenticationFilter

    <bean id="basicAuthenticationFilter"
      class="org.springframework.security.web.authentication.www.BasicAuthenticationFilter">
    <property name="authenticationEntryPoint" ref="BauthenticationEntryPoint"/>
    <property name="authenticationManager" ref="BauthenticationManager"/>
</bean>

                      

入口点和经理被这样描述:

  <bean id="BauthenticationEntryPoint"   class="org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint">
    <property name="realmName" value="Name Of Your Realm"/>
</bean>
<bean id="BauthenticationManager" class="org.springframework.security.authentication.ProviderManager">
    <property name="providers">
        <list>
            <ref local="ldapAuthProvider"/>
        </list>
    </property>
</bean>

最后

    <bean id="ldapAuthProvider"
      class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
    <constructor-arg>
        <bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
            <constructor-arg ref="contextSource"/>
            <property name="userDnPatterns">
                <list>
                    <value>sAMAccountName={0}</value>
                </list>
            </property>
        </bean>
    </constructor-arg>
    <constructor-arg>
        <bean
                class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator">
            <constructor-arg ref="contextSource"/>
            <constructor-arg value=""/>
        </bean>
    </constructor-arg>
</bean>

当我尝试访问/index.jsp时,我显示了一个stadart http auth窗口,它请求我输入我的用户名和密码。当我将其键入表单并按Enter时,没有任何操作 - 只需重新加载auth窗口即可。

我犯了哪个错误? 感谢。