How to override default Liferay Login authentication?

折月煮酒 提交于 2019-12-30 07:43:53

问题


I am using Liferay 6.1, and I want to override default Liferay Login authentication and want to set up my custom authentication.

Till now what I have done is, I have created a hook-plugin and have setup following properties in portal.properties file

auth.pipeline.pre=com.liferay.portal.security.auth.MyCustomAuthenticator
auth.pipeline.enable.liferay.check=false

where MyCustomAuthenticator is my custom authenticator class ( which implements Authenticator).

Currently, Liferay checks this custom authentication 1st, but then again it goes to Liferay itself for further Liferay authentication too.

I want to override this Liferay validation. Please help me solve this issue. Here is my authenticator class:

public class MyCustomAuthenticator implements Authenticator {  

  public int authenticateByEmailAddress(long arg0, String arg1, String arg2, Map<String, String[]> arg3, Map<String, String[]> arg4) throws AuthException {  

    System.out.println("succeeded by mail");  
    return SUCCESS;  
  }  

 public int authenticateByScreenName(long arg0, String arg1, String arg2, Map<String, String[]> arg3, Map<String, String[]> arg4) throws AuthException {  

    System.out.println("succeeded by screen name");  
    return SUCCESS;  
  }  

 public int authenticateByUserId(long arg0, long arg1, String arg2, Map<String, String[]> arg3, Map<String, String[]> arg4) throws AuthException {  

    System.out.println("succeeded by user id");  
    return SUCCESS;  
  }  

}  

回答1:


Add the following property in portal-ext.properties and then restart the server

auth.pipeline.enable.liferay.check=false



回答2:


Remembered in your hook project in file portal.properties

place auth.pipeline.pre =com.liferay.portal.security.auth.MyCustomAuthenticator 
auth.pipeline.enable.liferay.check = false

and also in the portal-ext-properties




回答3:


I had made a hook the same way, with these two lines in my hook portal.properties override, AND in portal-ext.properties for good measure:

auth.pipeline.pre=com.liferay.portal.security.auth.MyCustomAuthenticator
auth.pipeline.enable.liferay.check=false

However, it seemed to not want to login to Liferay even when the account already existed. I was able to get it fully working and skip Liferay authentication altogether. The hook overriding portal.properties is all I needed, I removed the 2 lines from portal-ext. In your Custom Authenticator, instead of just returning SUCCESS, (com.liferay.portal.security.auth.Authenticator.SUCCESS)

You want to return SKIP_LIFERAY_CHECK . This is the same as a SUCCESS, except making sure the authentication pipeline knows to skip the liferay check.

This should force it to work. I believe the source code (for Liferay 6.2 ga5) does not properly take into account the "Skip Liferay Check" property, and this essentially forces it.



来源:https://stackoverflow.com/questions/10634437/how-to-override-default-liferay-login-authentication

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!