掲示板

Changing Credentials In Flow :

9年前 に Mohit ... によって更新されました。

Changing Credentials In Flow :

New Member 投稿: 20 参加年月日: 14/02/28 最新の投稿
Hello,

I am having some concerns.
Let me give an example to make you better understand :

I want to override login mechanism , so i am using auto login hook and my requirement is :

1) I am having following users :
i) test@liferay.com
ii) abcd@liferay.com (Admin User)
iii) pqr@liferay.com
2) I am having one more custom table (lets say : myauthentication ) where i am having 2 columns (MyLoginId,EmailAddress);
In this Table my records would be :
MyLoginId - EmailAddress
MYID1 - test@liferay.com
MYID2 - abcd@liferay.com
3) Based on my requirement, In Login screen i will give "MYID1" as Email Address then the business flow should be :
a) first it should check whether input value is available in my custom table or not i.e.In "myauthentication" table as "MyLoginId" column. If
it is available then it would return the Emailaddress available in "myauthentication" table then this emailaddress would be used further to process (default liferay process). But if Data is not available in "myauthentication" table user shouldn't be able to Login.
Summary : I don't want to use EmailAddress directly, but i want to create a intermediate filter which will return the EmailAddress from Input
i.e. i want to change loginId in between the flow after submitting login request.

To do so I have done below sample code :

public class AutoLoginHook implements AutoLogin{

@Override
public String[] login(HttpServletRequest request,
HttpServletResponse response) throws AutoLoginException {
System.out.println("My Custome Auto Login Hoook");
String login=request.getParameter("_58_login");
System.out.println("Login ::"+login);
String [] credentials=new String [3];
if(login!=null){
/*My Code to get the EmailAddress from login field from my custom table ("myauthentication"), which will return EmailAddress*/
if(emailAddress!=null){
User user=UserLocalServiceUtil.getUserByEmailAddress(companyId, emailAddress);

credentials[0]=UserName of User;
credentials[1]=Password of User;
credentials[2]=Boolean.TRUE.toString();
}else{

credentials[0]=null;
credentials[1]=null;
credentials[2]=null;
}

}else{
credentials[0]=null;
credentials[1]=null;
credentials[2]=null;
}
return credentials;

}
}

I am facing below problem with this :
1) While Logging In from pqr@liferay.com i am able to successfully login, but i shouldn't be because this user doesn't exists in My custom table i.e. "myauthentication". (I think it is logged in beacuse its available in Liferay Demoticon
When i further debug it then i found that the After login : it calls AutoLoginFilter Then My Custom AutoLoginHook Then It Calls LoginAction (here it gets the Actual UserName and Password
from Login screen and process it).


Please let me know if you have any confusion related to understanding.
Thanks,
Mohit
thumbnail
9年前 に Tomas Polesovsky によって更新されました。

RE: Changing Credentials In Flow :

Liferay Master 投稿: 676 参加年月日: 09/02/13 最新の投稿
Hi,

I think the most secure way is to override UserLocalServiceImpl.authenticateBy* in Hook and:
1, call your authentication check
2, change the credentials and call super.authenticateBy*

Also make sure to disable other authentication options/SSO so that users won't be able authenticate to portal using other means.
9年前 に Mohit ... によって更新されました。

RE: Changing Credentials In Flow :

New Member 投稿: 20 参加年月日: 14/02/28 最新の投稿
Hi Tomas,

UserLocalServiceImpl.authenticateBy* is used for authentication in user_ table (liferay Demoticon, thats my second task,
first task is to replace the emailAddress sent from login screen.
i.e. simply if from login screen i sent MyId1 then in class i should be replace it to "test@liferay.com" .. how i can achieve this?


Thanks in advance.
thumbnail
9年前 に Tomas Polesovsky によって更新されました。

RE: Changing Credentials In Flow :

Liferay Master 投稿: 676 参加年月日: 09/02/13 最新の投稿
Hi Mohit ..., emoticon

you don't need auto login hook. AutoLogin hooks are used for SSO solutions.

You should ONLY need to override UserLocalServiceImpl.authenticateBy*. It's called from LoginUtil used by login portlet. There you can change the credentials, as I wrote above.

Please see Hooks documentation to see how to override UserLocalServiceImpl.

HTH.
9年前 に Mohit ... によって更新されました。

RE: Changing Credentials In Flow :

New Member 投稿: 20 参加年月日: 14/02/28 最新の投稿
Hi Tomas,

Thanks for response. emoticon
I think it would resolve my concern.
Let me check it and get back to u soon.

Please do let me know whats the use of Credentials[] in AutoLogin Hook?


Thanks,
thumbnail
9年前 に Tomas Polesovsky によって更新されました。

RE: Changing Credentials In Flow :

Liferay Master 投稿: 676 参加年月日: 09/02/13 最新の投稿
Mohit ...:
Please do let me know whats the use of Credentials[] in AutoLogin Hook?


They are used for JAAS redirect and probably can be used by other internal integrations like CMIS connector or others I don't know about emoticon