2017-05-10 32 views
1

我使用npmjs中的activedirectory module在我的一個節點應用程序中針對Active Directory進行身份驗證,我的問題是 - 是否需要在使用AD進行身份驗證時發送純字符串密碼?我的意思是,如果廣告存儲用戶密碼,它必須以某種方式或其他方式對其進行加密,那麼我們是否可以發送加密的密碼以進行身份​​驗證?這裏是我的意思是 -NPM - ActiveDirectory模塊身份驗證

ad.authenticate(username, password, function(err, auth) { 
// instead of plain password can it be encrypted password? 
if (err) { 
    console.log('ERROR: '+JSON.stringify(err)); 
    return; 
    } 

    if (auth) { 
    console.log('Authenticated!'); 
    } 
    else { 
    console.log('Authentication failed!'); 
    } 
}) 

回答

1

的解決方案是使用LDAPS(安全LDAP)和驗證提供CA,當你第一次連接。通過網絡發送的證書將被加密,如果您強制執行證書驗證,則MITM攻擊將無法工作。

const ActiveDirectory = require("activedirectory"); 
const ad = new ActiveDirectory({ 
    url: "ldaps://dc.domain.com", 
    baseDN: "dc=domain,dc=com", 
    username: "[email protected]", 
    password: "password", 
    tlsOptions: { 
     ca: [fs.readFileSync("CA.crt")], 
     rejectUnauthorized: true // Force Certificate Verification 
    } 
});