简体   繁体   English

使用LoginModule进行身份验证时出现问题

[英]Issue with authentication using a LoginModule

I am encountering a strange situation with MobileFirst 7.1 where users are occasionally unable to authenticate/login. 我在MobileFirst 7.1中遇到一种奇怪的情况,即用户有时无法进行身份验证/登录。 The only indication that something is awry is a message in the console.log 出现问题的唯一指示是console.log中的消息

[AUDIT ] CWWKS1100A: Authentication did not succeed for user ID . [AUDIT] CWWKS1100A:用户ID的认证未成功。 An invalid user ID or password was specified. 指定了无效的用户标识或密码。

My custom login module uses com.worklight.core.auth.ext.LdapLoginModule (so to clarify I have a login module which authenticates using LDAP). 我的自定义登录模块使用com.worklight.core.auth.ext.LdapLoginModule (因此,为了澄清我有一个使用LDAP进行身份验证的登录模块)。 Like I say everything seems to work most of the time but occasionally users end up in a situation where they are unable to authenticate. 就像我说的那样,大多数情况下一切似乎都有效,但是有时用户最终会遇到无法进行身份验证的情况。 I suspect that it is probably related to the session in some way, but that is only a guess based on my investigation. 我怀疑它可能与会话有某种关系,但这只是基于我的调查而得出的猜测。

I have added some logging to my 'secret' adapter which prints the session state to the console log , and obviously this appears in the logs just before the failed authentication message above, but it is empty ie. 我在“秘密”适配器中添加了一些日志记录,该日志记录将会话状态打印到console log ,并且很明显,这会出现在logs仅在上述身份验证消息失败之前,但它为空。 the session contains nothing.The user is obviously trying to access a secure adapter at this point, and because they are not authenticated they end up at the login page (form based authentication I should say also). 会话没有任何内容。此时,用户显然正在尝试访问安全适配器,并且由于未通过身份验证,因此它们最终出现在登录页面(基于表单的身份验证)。

Anyway, I noticed that although there appears to be no session data, the jsessionid is there and has not changed ie it does not change even if I refresh the browser. 无论如何,我注意到尽管似乎没有会话数据,但jsessionid存在并且没有更改,即,即使刷新浏览器也不会更改。 This may not be an issue in itself of course, but interestingly if I remove this entry and refresh my browser I am able to login successfully. 当然,这本身可能不是问题,但是有趣的是,如果删除此条目并刷新浏览器,我就能成功登录。

I am pretty sure that my handler code calls the relevant success/failure methods in the correct places but of course there is nothing to stop the user refreshing their browser, which causes them to be re-directed to the login page (the app has been developed using AngularJS so is effectively a single-page navigation model). 我很确定我的处理程序代码在正确的位置调用了相关的success/failure方法,但是当然没有什么可以阻止用户刷新浏览器,这导致它们重新定向到登录页面(该应用程序已经是使用AngularJS开发的,因此实际上是单页导航模型)。

The only reproducible test I have been able to come up with is when I login to the MobileFirst console and then try to login to our MF 'desktopbrowser' app. 我能够提出的唯一可重现的测试是,当我登录到MobileFirst控制台,然后尝试登录到我们的MF'desktopbrowser'应用程序时。 I have read that this situation causes a session-related conflict, but as I say the occasional issue I am seeing is not caused by this (though it may be related). 我已经读过这种情况会导致与会话相关的冲突,但是正如我所说的,我偶尔看到的问题不是由此引起的(尽管可能是相关的)。

So the problem seems to have been more related to the flow of logic in our application after successfully logging in, than any inherent issue with the MF Platform. 因此,问题似乎与成功登录后我们应用程序中的逻辑流有关,而不是MF平台固有的问题。

For example when a user refreshes the browser they are effectively still logged in, but because the app (based on logic we have developed) takes the user to the login page on refresh, the user is effectively re-logging in to the same session. 例如,当用户刷新浏览器时,他们仍然有效地登录,但是由于该应用程序(基于我们开发的逻辑)在刷新时会将用户带到登录页面,因此该用户实际上是在重新登录到同一会话。 If this failed every time it would of course have been easier to pinpoint but it does not. 如果每次都失败,那么查明它当然会容易些,但事实并非如此。 The solution was to force logout on refresh (when the app initialises), thus cleaning up any session data. 解决方案是在刷新时(应用初始化时)强制注销,从而清除所有会话数据。 In future iterations it may of course be better to re-establish the application based on the authenticated session after refresh, but at present that was a step too far. 当然,在将来的迭代中,刷新后根据经过身份验证的会话重新建立应用程序当然会更好,但是目前这已经太过分了。

Another example of this was post login if the subsequent adapter calls failed (eg we authenticate and then retrieve profile data from a database), then we were also not logging the successfully authenticated user out. 另一个例子是如果后续适配器调用失败(例如,我们先进行身份验证然后从数据库中检索配置文件数据),则为登录后登录,那么我们也不会注销成功身份验证的用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM