I am currently working on a Worklight 6.0 POC using the Header Authentication authentication/login module. When attempting to access a protected adapter in the app I receive the following error in the console:
403 (Forbidden)
TypeError: Object # has no method 'handleFailure'
I receive this error when testing the web version of the app via the console in chrome.
I also get a similar error when testing on the iPhone version of the app. exception. TypeError: 'undefined' is not a function (evaluating 'handler.handleFailure(wlFailure[realm])')
Looking through the wlclient.js file within the AbstractChallengeHandler class/function I am not seeing a function definition for handleFailure which explains the above error. I assume there should be a definition for handleFailure or are there more configurations that are need for protecting an adapter resource using Header Authentication?
My reason for asking this question, is that I am trying to test my logic in the client side "ChallengeHandler" piece that I have created, and I am trying to understand why I am not able to see this type of error/response via the normal client side challenger.isCustomResponse/challenger.handleChallenge communication.
Code/configuration is below
Any advice/input is appreciated
authenticationConfig.xml
<securityTests>
<webSecurityTest name="WebSecurityTest">
<testUser realm="HeaderAuthRealm"/>
</webSecurityTest>
<mobileSecurityTest name="MobileTest">
<testUser realm="HeaderAuthRealm"/>
<testDeviceId provisioningType="none"/>
</mobileSecurityTest>
<customSecurityTest name="HeaderAuth-securityTest">
<test realm="HeaderAuthRealm" isInternalUserID="true" />
</customSecurityTest>
</securityTests>
<realms>
<realm name="HeaderAuthRealm" loginModule="HeaderLoginModule">
<className>com.worklight.core.auth.ext.HeaderAuthenticator</className>
</realm>
</realms>
<loginModules>
<loginModule name="HeaderLoginModule">
<className>com.worklight.core.auth.ext.HeaderLoginModule</className>
<parameter name="user-name-header" value="HeaderAuth_USER"/>
</loginModule>
</loginModules>
HeaderAuthRealmChallenger.js
var HeaderAuthRealmChallenger = WL.Client.createChallengeHandler("HeaderAuthRealm");
HeaderAuthRealmChallenger.isCustomResponse = function(response) {
if (response.responseJSON.isSuccessful) {
WL.Logger.info('AUTHENTICATION SUCCESS =).......');
return false;
}else{
return true;
}
};
HeaderAuthRealmChallenger.handleChallenge = function(response){
WL.Logger.info('AUTHENTICATION FAILED =(.......');
$('#login').css('display','block');
};