-
Multiple login features
I would like to give the client the possibility to choose to login to my application either using google, facebook or my own implemented user data.
What I have so far is, I created my own CustomUserDetailsService class, which is working fine. I'm looking up the database and check if user exist and the password is equal. Now, I would like to extend the authentication to be able to use for example the google openId.
I was thinking of creating a new CustomUserDetailsServiceGoogle which implements UserDetailsService, but of course it failse because it expects only one implemantation of UserDetailsService.
My app-security.xml looks like this:
HTML Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<global-method-security pre-post-annotations="enabled" />
<http use-expressions="true" auto-config="true">
<intercept-url pattern="/account/**" access="hasRole('ROLE_USER')" />
<form-login login-page="/auth/login"
authentication-failure-url="/auth/denied"
default-target-url="/account/profile" />
<access-denied-handler error-page="/auth/denied" />
<logout invalidate-session="true"
logout-success-url="/"
logout-url="/logout"
delete-cookies="JSESSIONID" />
<remember-me />
<session-management invalid-session-url="/" />
</http>
<beans:bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" />
<beans:bean id="customUserDetailsService" class="com.app.security.CustomUserDetailsService" />
<authentication-manager>
<authentication-provider user-service-ref="customUserDetailsService">
<password-encoder ref="passwordEncoder"/>
</authentication-provider>
</authentication-manager>
</beans:beans>
Does anyone have a link to an example of supporting 2 or many authentication features?