Announcement Announcement Module
No announcement yet.
Help in Authentication Provider Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help in Authentication Provider

    I have restful web service where BASIC Auth implemented. As of now the authentication is based on default user and password

        <http auto-config="true">
            <intercept-url pattern="/welcome*" access="ROLE_USER" />
                    <user name="user" password="password" authorities="ROLE_USER" />
    But I would like to pass the username and password from the http headers to bean which has the ldap authentication methods.

  • #2
    You can use the LdapAuthenticationProvider built in to Spring Security, or implement custom UserDetailsService and AuthenticationProvider and use own code for communicating with LDAP.

    Read first something about the built in Ldap authentication, and if it does not match your specification, than try the second one.

    In my present project for example we have the user rights in DB and the passwords in LDAP, so I impelmented a custom UserDetailsService and AuthenticationProvider and do the following setup:

    HTML Code:
    	<authentication-manager alias="authenticationManager">
                 <authentication-provider ref="authenticationProvider" />
    	<beans:bean id="authenticationProvider" class="myAuthenticationProvider">
                    <beans:property name="userDetailsService" ref="userDetailsService" /> 
    	<beans:bean id="userDetailsService" class="myUserDetailsService">
    My userDetailsService populates a UserDetails Object with the roles of the present user, and then my
    authenticationProvider runs some custom LDAP search for password checking.


    • #3
      But my issues is in my app, the username in Basic authorization will be like 'User#emailaddress' and the password is 'secret'.

      Now I have to write custom authentication filter that reads username from HTTP headers and parse to get email address and username.Then I need to pass these 3 values [ emailID, username and password ] to a existing method which does ldap authentication.


      • #4
        Why custom filter?

        As I know, you need no custom Filter. If you want to parse the submitted username, you can do it in your UserDetailsService and/or AuthenticationProvider. Please, check an example with custom LDAP Authentication from the web, or the corresponding section in the Spring Security Docs