Announcement Announcement Module
Collapse
No announcement yet.
Custome UserDetailsService not loading Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custome UserDetailsService not loading

    Hi,
    I`m using spring-security M2.
    I`m trying to use the default security config with a custom UserDetailsService as shown in the config below:-

    Code:
    ?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:security="http://www.springframework.org/schema/security"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                  http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd"> 
    		
    	<security:http auto-config='true'>
        	<security:intercept-url pattern="/**" access="ROLE_ANONYMOUS" />
      	</security:http>
      
     
     	
      	<security:authentication-provider user-service-ref="myUserDetailsService"/>
     
    	    <bean id="myUserDetailsService" class="com.mycompany.userdetails.MyUserDetailsService">
    	  	<property name="applicationNames">
    	  		<list>
    	  			<value>app1</value>
    	  			<value>app2</value>
    	  		</list>
    	  	</property>
    	  </bean>
    	  
    
    </beans>
    When I run my application I`m getting:
    java.lang.IllegalArgumentException: No UserDetailsService registered.
    at org.springframework.security.config.ConfigUtils.ge tUserDetailsService(ConfigUtils.java:81)
    at org.springframework.security.config.HttpSecurityCo nfigPostProcessor.injectUserDetailsServiceIntoReme mberMeServices(HttpSecurityConfigPostProcessor.jav a:60)
    at org.springframework.security.config.HttpSecurityCo nfigPostProcessor.postProcessBeanFactory(HttpSecur ityConfigPostProcessor.java:44)


    However if I change the config to be :

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:security="http://www.springframework.org/schema/security"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                  http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd"> 
    		
    	<security:http auto-config='true'>
        	<security:intercept-url pattern="/**" access="ROLE_ANONYMOUS" />
      	</security:http>
      
      <security:authentication-provider>
      <security:user-service>
        <security:user name="user" password="user"
          authorities="ROLE_ADMIN, ROLE_USER" />
      </security:user-service>
    </security:authentication-provider>
     
    </beans>
    My application starts.So its as if the
    user-service-ref="myUserDetailsService"
    in my first config is being ignored.

    Does anyone have a similar issue or solution?

  • #2
    Wrong UserDetailsService interface was being used

    Ok I found out that theres 2 UserDetailsService interfaces in the spring-core M2 jar

    org.springframework.security.providers.UserDetails Service

    and

    org.springframework.security.userdetails.UserDetai lsService

    My Config now loads ok

    Comment


    • #3
      There should only be the one UserDetailsService interface - in the userdetails package.

      Comment


      • #4
        Hi Luke,

        I thought that as well but I just downloaded the spring-security-core-2.0-M2.jar and opened in winzip and theres definatly 2 UserDetailsService.See attached jpeg for winzip output.

        Darran

        Comment


        • #5
          I`ve now checked the 2.01 snapshot and that appears to only have a single UserDetailsService.

          Comment

          Working...
          X