我正在使用express-ntlm在intranet设置中获取当前用户的windows ID。它在大多数情况下工作得很好,但偶尔会返回一个完全不同的人的ID。我猜这可能和会话有关吧?
const ntlm = require('express-ntlm');
module.exports = app => {
app.use(
ntlm({
debug: function() {
var args = Array.prototype.slice.apply(arguments);
console.log.apply(null, args);
},
domain: 'MS',
domaincontroller: 'ldap://something.com'
})
);
app.post('/get-user-details/', (req, res) => {
console.log(req.ntlm.UserName); //Returns correct user most of the time, but sometimes it returns different person who open site at the same time
});发布于 2019-05-26 21:57:18
不幸的是,NTLM验证的是连接,而不是会话。这在过去是很好的,但现在已经没有意义了,因为浏览器倾向于一次打开多个连接来加快页面加载速度,而反向代理则共享到后端的连接。这就是问题所在:您的反向代理将重用已经通过身份验证的连接到后端,因此会混淆用户。要缓解此问题,必须确保您的反向代理启用了NTLM支持。
仍然有一个用于express-ntlm的open pull request,它添加了一个Keep-Alive属性,可以解决这个问题,不幸的是,它还没有经过广泛的测试,首先需要验证。
https://stackoverflow.com/questions/54404505
复制相似问题