Kullanıcı adı ve parola doğrulamak için node.js web hizmetini kullanan bir http bağdaştırıcısı üzerinde çalışıyorum.IBM Mobile First 7.1 HTTP Bağdaştırıcısı Güvenlik testi
Prosedürler authentineHizmet ve authenticateDoctor korunmasız olduğundan güvenlik prosedürünü diğer prosedürlerde kullanacağım.
Ancak, bunlardan birini çağırmaya çalıştığımda, bu güvenlik açığından etkilenmemekle birlikte, sorun gidericiye de çağrılır ve eğer sorun gidericisini silersem, iyi çalışır!
PatientAuthRealmChallengeHandler.js
var patientAuthRealmChallengeHandler = WL.Client.createChallengeHandler("PatientAuthRealm");
patientAuthRealmChallengeHandler.isCustomResponse= function(response){
if(!response|| !response.responseJSON || response.responseText===null){
return false;
}
if(typeof (response.responseJSON.authRequired)!== 'undefined'){
return true;
}
else {
return false;
}
}
patientAuthRealmChallengeHandler.handleChallenge = function(response){
var authRequired = response.responseJSON.authRequired;
if(authRequired==true){
console.log("accées réfusé!!");
}
else if(authRequired==false){
console.log(" déja authentifié ");
patientAuthRealmChallengeHandler.submitSuccess();
}
}
Authentication.xml
<procedure name="authenticatePatient" securityTest="wl_unprotected"/>
<procedure name="authenticateDoctor" securityTest="wl_unprotected"/>
Doğrulama-impl.js (sadece authenticatePatient fonksiyonu)
function authenticatePatient(params){
var url="/patient/authenticate";
var response= callWS(url,params,"post");
var size= response.patients.length;
if(size!=0){
userIdentity = {
userId: params.username,
displayName: params.username,
attributes: {
}
};
//WL.Server.setActiveUser("PatientAuthRealm", null);
WL.Server.setActiveUser("PatientAuthRealm", userIdentity); // create session
return {
authRequired: false,
"response": response
};
}
return onAuthRequired(null, "Invalid login credentials");
}
function onAuthRequired(headers, errorMessage){
errorMessage = errorMessage ? errorMessage : null;
return {
authRequired: true,
errorMessage: errorMessage
};
}
function onLogout(){
WL.Logger.debug("Logged out");
}
authentificationConfig.xml (alanları)
<realm name="PatientAuthRealm" loginModule="PatientAuthLoginModule">
<className>com.worklight.integration.auth.AdapterAuthenticator </className>
<parameter name="login-function" value="authentication.onAuthRequired"/>
<parameter name="logout-function" value="authentication.onLogout"/>
</realm>
<realm name="DoctorAuthRealm" loginModule="DoctorAuthLoginModule">
<className>com.worklight.integration.auth.AdapterAuthenticator </className>
<parameter name="login-function" value="authentication.onAuthRequired"/>
<parameter name="logout-function" value="authentication.onLogout"/>
</realm>
authentificationConfig.xml (LoginModule)
<loginModule name="PatientAuthLoginModule">
<className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
</loginModule>
<loginModule name="DoctorAuthLoginModule">
<className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
</loginModule>
authentificationConfig.xml (Güvenlik testleri)
<customSecurityTest name="authenticatePatient">
<test isInternalUserID="true" realm="PatientAuthRealm"/>
</customSecurityTest>
<customSecurityTest name="authenticateDoctor">
<test isInternalUserID="true" realm="DoctorAuthRealm"/>
</customSecurityTest>