RE: RE: Adding Custom Login Flow for Liferay Portal

Jamie Sammons, modified 2 Years ago. New Member Posts: 18 Join Date: 4/11/23 Recent Posts

Hi All,

I have a requirement to customise the authentication flow of the Liferay. I have to authenticate users by calling an external API with user name and password after that I have to invoke Liferay's open Id authentication (Azure AD) as the secondary authentication via code to get the user authenticated with some state parameters. I have followed below URL for creating the Custom Login Portlet but after deploying its still showing the default Sigin In form on clicking the Sigin In button from the portal. 

Writing a Custom Login Portlet – Liferay Help Center

  1. Could some one already done similar scenario, explain how we can configure or deploy the above mentioned Custom Login Portlet in liferay-ce-portal-7.4.3.70-ga70 bundle.
  2. Is it possible to invoke OpenId authentication via code after primary login?

 

thumbnail
Mohammed Yasin, modified 2 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts

Hi,

You can consider using Pre/Post Liferay Authentication Pipelines. This can be used for additional check Pre or Post Default Authentication.

Refer https://help.liferay.com/hc/en-us/articles/360018161751-Password-Based-Authentication-Pipelines 

Jamie Sammons, modified 2 Years ago. New Member Posts: 18 Join Date: 4/11/23 Recent Posts

Thank You Mohammed Yasin,

I am wondering why the following implementation is not working because this documentation says this is the process for completely customizing the Login.

Writing a Custom Login Portlet – Liferay Help Center

Also could you please suggest how we can disable or bypass Liferay's default username password authentication in Pre authentication event and use my own external service to authenticate the user and then call OpendID endpoint to initiate the SSO.

thumbnail
Mohammed Yasin, modified 2 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts

You can try  returning  Authenticator.SKIP_LIFERAY_CHECK in Pre-Authentication. This would bypass Liferay Authentication. 

Jamie Sammons, modified 2 Years ago. New Member Posts: 18 Join Date: 4/11/23 Recent Posts

Thank You for your reply.

I was able to customize the login page by creating "Liferay Module Project Fragment" project and overriding login.jsp file under the OSGi bundle "com.liferay.login.web-6.0.37.jar" file. Also I was able to call external service for authentication by creating a MVCActionCommand portlet with "mvc.command.name=/login/login". Upto this part I have done and its working. The next I have to call OpenId authentication with some state parameter from my MVCActionCommand portlet.

How we can call OpenId authentication from the portlet processRequest method?

I have tried following redirect from processRequest and its working. But not sure its the right way and how to set my own state/relay parameter to the IDP login request.

actionResponse.sendRedirect("/search?p_p_id=com_liferay_login_web_portlet_LoginPortlet&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&_com_liferay_login_web_portlet_LoginPortlet_mvcRenderCommandName=%2Flogin%2Fopenid_connect_request&saveLastPath=false");

Please advice