Spring Security LDAP-未注册UserDetailsS​​ervice [英] Spring Security LDAP - No UserDetailsService registered

查看:144
本文介绍了Spring Security LDAP-未注册UserDetailsS​​ervice的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置LDAP Spring Security.而且我遇到了一些奇怪的异常:

I'm trying to set up the LDAP Spring Security. And I've stucked with some strange exception:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterChainList'
...
No UserDetailsService registered

我的security-config.xml看起来像这样:

My security-config.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://www.springframework.org/schema/security"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">

    <sec:global-method-security secured-annotations="enabled"
                access-decision-manager-ref="accessDecisionManager" />

    <sec:http auto-config="true">
        <sec:intercept-url pattern="/css/**" filters="none" />
        <sec:intercept-url pattern="/js/**" filters="none" />
        <sec:intercept-url pattern="/img/**" filters="none" />

        <sec:intercept-url pattern="/login" access="IS_AUTHENTICATED_ANONYMOUSLY" />
        <sec:intercept-url pattern="/login" access="IS_AUTHENTICATED_ANONYMOUSLY" method="POST" />
        <sec:intercept-url pattern="/uzivatel/registrace" access="IS_AUTHENTICATED_ANONYMOUSLY" />

        <sec:intercept-url pattern="/**" access="ROLE_UZIVATEL" />

        <sec:form-login default-target-url="/vlakna" login-page="/login"  />
    </sec:http>

    <bean id="accessDecisionManager" class="org.springframework.security.vote.ConsensusBased">
        <property name="decisionVoters">
            <list>
                <ref bean="rightsAccessDecisionVoter" />
            </list>
        </property>
    </bean>

    <bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
        <constructor-arg value="ldap://111.111.111.111"/>
        <property name="userDn" value="cn=auth-user,ou=System,dc=sh,dc=company,dc=com"/>
        <property name="password" value="secret"/>
    </bean>

    <bean id="ldapAuthProvider" class="org.springframework.security.providers.ldap.LdapAuthenticationProvider">
        <sec:custom-authentication-provider/>
        <constructor-arg>
            <bean class="org.springframework.security.providers.ldap.authenticator.BindAuthenticator">
                <constructor-arg ref="contextSource"/>
                <property name="userSearch">
                    <bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
                      <constructor-arg index="0" value="ou=People,dc=sh,dc=company,dc=com"/>
                      <constructor-arg index="1" value="(uid={0})"/>
                      <constructor-arg index="2" ref="contextSource" />
                    </bean>
                </property>
                <property name="userDnPatterns">
                    <list><value>uid={0},ou=people</value></list>
                </property>
                <property name="userAttributes">
                    <list><value></value></list>
                </property>
            </bean>
        </constructor-arg>
        <constructor-arg>
            <bean class="cz.rohan.dusps.services.UzivatelAuthoritiesPopulator" />
        </constructor-arg>
    </bean>

    <bean id="rightsAccessDecisionVoter" class="com.company.RightsAccessDecisionVoter" />
</beans>

我认为应该将"ldapAuthProvider"作为用户详细信息服务,但事实并非如此.有人在我的配置中看到任何问题吗?

I thought that it should take "ldapAuthProvider" as an user details service but it doesn't. Does anybody see any problem in my config?

感谢您的帮助, Mateo

Thanks for any help, Mateo

推荐答案

我认为...

<bean id="ldapAuthProvider" class="org.springframework.security.providers.ldap.LdapAuthenticationProvider">
<security:custom-authentication-provider />
// MISSING ABOVE
<property name="userDetailsService" ref="ldapUserDetailsService" />
.....

这篇关于Spring Security LDAP-未注册UserDetailsS​​ervice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆