0

I have a login form with username and password. Now, I want to another field (I call switch field), this field helps users can switch between 2 login Provider in Spring security (I mean that user input username and password, then choose the way to authenticate - LDAP or Database)

I have 2 authentication-manager like below

<security:authentication-manager alias="ldapAuthenticationManager">
    <security:authentication-provider
        ref="ldapAuthProvider" />
</security:authentication-manager>


<security:authentication-manager id="dBAuthenticationManager">
    <security:authentication-provider
        user-service-ref="userDetailsService">
    </security:authentication-provider>
</security:authentication-manager>

I do not know how to catch the extra param (switch field) and switch between 2 Provider above.

I am very stuck in this case. Thanks.

Jerry
  • 185
  • 1
  • 6
  • 18
  • From a security point of view, I'm curious why you would let the user choose its authentication provider (he shouldn't have to be aware of the internals of your system). Anyway, if you declare both providers in the same authentication manager, a user will be authenticated against the first provider you declare, and if not found, Spring will then try to authenticate the user against the second provider. Do you really need the switch? – Marc Tarin May 03 '17 at 08:26
  • Thank for your suggest, but I really need switch, that is requirement. – Jerry May 03 '17 at 08:32
  • I am stuck, how to get the extra param from UI (beside username and password) ? – Jerry May 03 '17 at 08:33
  • Check this [thread](http://stackoverflow.com/questions/10074308/how-to-pass-an-additional-parameter-with-spring-security-login-page). – Marc Tarin May 03 '17 at 08:57

0 Answers0