我有一个使用适配器身份验证的MobileFirst Platform 6.3应用程序。用户必须能够在会话中多次登录和注销,切换凭证(即登录为“userA”,注销,登录为“userB”,注销等)。只要会话保持活动状态,所有这一切都可以正常工作。
如果我将我的应用程序放在后台20-30分钟,我会在服务器日志中看到我的logout-function
(onLogout)被调用了。我假设当会话超时时框架会调用它。我的onLogout调用了WL.Server.setActiveUser("RealmName", null)
,所以这会使会话失效,它确实会这样做。
当用户将应用程序带回前台并尝试调用受保护的过程时,会出现问题。我在服务器日志中看到框架调用了我的login-function
(onAuthRequired)。 message参数未定义。 headers参数包含类似
{"Cookie":["WL_PERSISTENT_COOKIE=5a39bf15-b217-40c2-97eb-c6622213e799; JSESSIONID=00003dozYVeiAYXJYzoQf_oG6BI:5702d236-4455-4e22-bf0c-132459018524"],"Host":["192.168.1.64:10080"],"WL-Instance-Id":["4rjpubf76afnvs9l61gtkf197t"],"X-Requested-With":["XMLHttpRequest"],"Content-Length":["198"],"x-wl-clientlog-deviceId":["DE67FB50-5ABD-4418-A39D-69058144454F"],"x-wl-clientlog-model":["iPad5,4"],"User-Agent":["Mozilla/5.0 (iPad; CPU OS 8_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12D508/Worklight/6.3.0.0 (358300384)"],"x-wl-clientlog-osversion":["8.2"],"x-wl-clientlog-appname":["Greenwell"],"Connection":["keep-alive"],"x-wl-device-id":["B405CAA3-4EE6-4581-9004-5AA8AA950E0A"],"x-wl-clientlog-appversion":["1.2.1"],"x-wl-app-version":["1.2.1"],"Accept-Language":["en-US"],"x-wl-analytics-tracking-id":["5A9D03E9-42FA-41E7-9FFD-69C4EE89EF95"],"Authorization":["{\"wl_deviceNoProvisioningRealm\":{\"ID\":{\"token\":\"q0dhk0eutb0gi53ak2mltrlbkv\",\"app\":{\"id\":\"GreenwellBanking\",\"version\":\"1.2.1\"},\"device\":{\"id\":\"B405CAA3-4EE6-4581-9004-5AA8AA950E0A\",\"os\":\"8.2\",\"model\":\"iPad5,4\",\"environment\":\"ipad\"},\"custom\":{}}}}"],"Accept-Encoding":["gzip, deflate"],"x-wl-app-details":["{\"applicationDetails\":{\"platformVersion\":\"6.3.0.0\",\"nativeVersion\":\"1889110191\",\"skinName\":\"default\",\"skinChecksum\":2615010882,\"skinLoaderChecksum\":\"(null)\"}}"],"Content-Type":["application/x-www-form-urlencoded; charset=UTF-8"],"Accept":["text/javascript, text/html, application/xml, text/xml, */*"],"x-wl-clientlog-env":["ipad"]}.
调用WL.Client.invokeProcedure
调用的成功处理程序和失败处理程序都不会被调用。日志中似乎有一个响应显示authRequired:true。
2015-03-25 10:44:16.937 Greenwell[649:305965] [DEBUG] [NONE] fetching offers
2015-03-25 10:44:16.964 Greenwell[649:305965] [DEBUG] [NONE] Request [/apps/services/api/GreenwellBanking/ipad/query]
2015-03-25 10:44:16.967 Greenwell[649:305968] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] +[WLAFHTTPClientWrapper requestWithURL:] in WLAFHTTPClientWrapper.m:37 :: Request url is http://192.168.1.64:10080/GreenwellBanking/apps/services/api/GreenwellBanking/ipad/query
2015-03-25 10:44:16.977 Greenwell[649:305968] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper start] in WLAFHTTPClientWrapper.m:182 :: Starting the request with URL http://192.168.1.64:10080/GreenwellBanking/apps/services/api/GreenwellBanking/ipad/query
2015-03-25 10:44:17.116 Greenwell[649:286631] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:195 :: Request Success
2015-03-25 10:44:17.119 Greenwell[649:286631] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:196 :: Response Status Code : 200
2015-03-25 10:44:17.122 Greenwell[649:286631] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:197 :: Response Content : /*-secure-
{"errorMessage":null,"isSuccessful":true,"authRequired":true}*/
challengeHandler
var challengeHandler = WL.Client.createChallengeHandler("CaasAuthRealm");
challengeHandler.isCustomResponse = function(response) {
if (!response || !response.responseJSON || response.responseText === null) {
return false;
}
if (typeof(response.responseJSON.authRequired) !== 'undefined'){
return true;
} else {
return false;
}
}
challengeHandler.handleChallenge = function (response) {
var authRequired = response.responseJSON.authRequired;
console.log("Handling Challenge - authRequired = " + authRequired);
if (authRequired) {
challengeHandler.submitFailure("Bad credentials");
$.mobile.changePage("login.html", {transition: "slide"});
} else {
challengeHandler.submitSuccess();
if (Model.getInstance().username == "wcmaas-anonymous") {
$.mobile.changePage( "landing.html", { transition: "flip", reverse: true } );
} else {
$.mobile.changePage( "home.html", { transition: "flip" } );
}
}
}
问题:
onAuthRequired
,为什么我没有看到向应用程序发出的质询?如果我这样做,我可以提示用户再次登录。WL.Client.invokeProcedure
中正确地使会话无效,但是如何在没有挑战的情况下提示用户重新进行身份验证?答案 0 :(得分:0)
您最有可能使用适配器身份验证,忘记在质询处理程序中使用submitSuccess()。您能否提供有关身份验证配置的更多详细信息并粘贴质询处理程序代码?