Use third party authentication service in Liferay


This blog quickly describe, how to hook the third party authentication services to use Liferay standard auhentication.

Liferay provides very rich set of connections for authentication, still many times we come across situations where we have to use some third party non standard (like proprietary solution) for authentication.

The following shows how to do that quickly.

1. Create a liferay hook

Create a new liferay hook to hook UserLocalService for custom authentication. Follow this link on how to create a liferay hook

In this hook, implement a UserLocalServiceWrapperImpl class which implements com.liferay.portal.service.UserLocalServiceWrapper. This class will have the implementation of your desired authentication method.

Let say, you are using authentication by email address in Liferay, so in that case, please override method authenticationByEmailAddess(). in the method implementation, you can call you custom service or third party authentication service for the authentication. You have the user provided email address and password as method parameter, so you can easily send them.

Based on the result of you authentication process, you can return the or FAILURE.

public int authenticateByEmailAddress(long companyId, String emailAddress, String password,
Map headerMap, Map parameterMap, Map resultsMap)
throws SystemException, PortalException {"Calling authenticateByEmailAddress");        

try {
//call your custom authentication service
boolean result = CustomAuthenticationServiceUtil.authenticate(emailAddress, password);

if(result) {
return Authenticator.SUCCESS;
return Authenticator.FAILURE;
} catch (Exception e) {
LOG.error("authentication failed by :",e);
return Authenticator.FAILURE;

2. Hook the service

Open the liferay-hook.xml and add the below code


3. Now, deploy the hook. Whenever you will use the Liferay login portlet, Liferay will call the hooked service and there you go

Happy coding!