Announcement Announcement Module
Collapse
No announcement yet.
How to configure multiple providers in a single Authentication Manager Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to configure multiple providers in a single Authentication Manager

    Hi,

    I have a requirement where I need to do authentication from using LDAP and authorization from the local database. I tried to search for the solution for this, but did not have any success.

    Any reply in this regard would be a great help.

    Regards,
    Maulik

  • #2
    Hi Maulik,

    you can add multiple providers to the authenticationManager by providing the ProviderManager (getProviders() as constructor arg). See the code below:

    ----------
    Code:
    	@Bean
    	public AuthenticationManager authenticationManager() {
    		ProviderManager manager = new ProviderManager(getProviders());
    		return manager;
    	}
    
    	@Bean
    	public UserDetailsService userDetailsService() {
    		return new JPAUserDetailsService();
    	}
    
    	@Bean
    	public AuthenticationProvider daoAuthenticationProvider() {
    		DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    		provider.setUserDetailsService(userDetailsService());
    		return provider;
    	}
    
    	public List<AuthenticationProvider> getProviders() {
    		List<AuthenticationProvider> providers = new ArrayList<AuthenticationProvider>();
    		providers.add(daoAuthenticationProvider());
    		return providers;
    	}
    ----
    Last edited by vonbrittelstrausse; Jan 23rd, 2012, 01:58 PM.

    Comment


    • #3
      Did you see the FAQ?

      Comment

      Working...
      X