Worklight Studio 6.0.0.2; Worklight Server 6.0.0; Hybrid app on Android;
Recently, I found another strange behavior with Worklight Adapter-based authentication. It is that the #7 step below doesn't happen for me (The following 7 steps are copies from Anton's one answer) in case of that I passed the auth at the beginning, and then run app in the background. After Worklight session expired, return app to the foreground. At this time, the first request won't get response when re-auth with WL server.
Android logs:
D/NONE(19720): Request [https://xxx/android/composite]
D/NONE(19720): auth required: true
D/NONE(19720): re-submit custom auth
D/NONE(19720): Request [https://xxx/../../invoke]
D/NONE(19720): auth required: false
D/NONE(19720): response.responseJSON: {"isSuccessful":true,"authRequired":false}
D/NONE(19720): Request [https://xxx/android/composite]
See? Not get response of "composite" request. Actually, I also don't get response of other #1 request in some case, which causes my app cannot proceed. In this case, I have to send two same requests: one goes away without reponse; another one works well.
Any idea? Thanks in advance.
Updates:
Via PC browser, I found the request of #6 step got 403 error...;
My some codes:
pushAppRealmChallengeHandler.handleChallenge = function(response){
var authRequired = response.responseJSON.authRequired;
var loginForm = registry.byId("loginPage");
if(authRequired){
WL.Logger.debug("auth required: " + authRequired);
if(response.responseJSON.errorMessage != null){
mBase.showProgressIndicator();
loginForm.hintNode.innerHTML = response.responseJSON.errorMessage;
loginForm.usernameNode.domNode.focus();
}else{
WL.Logger.debug("re-submit custom auth");
pushAppRealmChallengeHandler.doCustomAuth(loginForm.usernameNode.get('value'), loginForm.passwordNode.get('value'));
}
}else if(authRequired == false){
WL.Logger.debug("auth required: " + authRequired);
if(!pushAppRealmChallengeHandler._authFinished){
pushAppRealmChallengeHandler._authFinished = true;
...
pushAppRealmChallengeHandler.submitSuccess();
}else {
WL.Logger.debug("response.responseJSON: " + dojo.toJson(response.responseJSON));
pushAppRealmChallengeHandler.submitSuccess();
}
}
};
pushAppRealmChallengeHandler.doCustomAuth = function(userName, password) {
var loginForm = registry.byId("loginPage");
var invocationData = {
adapter : "AuthAdapter",
procedure : "submitAuthentication",
parameters : [Base64.encode(userName), Base64.encode(password), userName, pushAppRealmChallengeHandler._authFinished]
};
pushAppRealmChallengeHandler.submitAdapterAuthentication(invocationData, {
onFailure : function() {
mBase.showProgressIndicator();
loginForm.hintNode.innerHTML = Messages.WLErrMsg;//netErrMsg;
}
});
};
My team fixed this issue by changing the configuration of mobileSecurityTest. An reason is that one of test realm doesn't give the response. So, my team remove that test realm belong to mobileSecurityTest.
Old
<mobileSecurityTest name="PushApplication-strong-mobile-securityTest">
<testUser realm="PushAppRealm"/>
<testDeviceId provisioningType="none"/>
</mobileSecurityTest>
New
<customSecurityTest name="PushApplication-strong-mobile-securityTest">
<test realm="wl_remoteDisableRealm"/>
<test realm="PushAppRealm" isInternalUserID="true"/>
<test realm="wl_deviceNoProvisioningRealm" isInternalDeviceID="true" />
</customSecurityTest>