Node.js 快速ntlm返回错误的用户
我正在使用在intranet设置中获取当前用户的windows ID。它在大多数情况下工作正常,但偶尔会返回完全不同的人的ID。我猜这可能和治疗有关吧Node.js 快速ntlm返回错误的用户,node.js,express-ntlm,Node.js,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)
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
});
不幸的是,NTLM认证的是连接,而不是会话。这在过去很好,但不再有意义,因为浏览器倾向于一次打开多个连接以加速页面加载,而反向代理正在共享到后端的连接。这就是问题所在:反向代理将重用已通过身份验证的后端连接,从而混淆用户。要缓解此问题,必须确保反向代理已启用NTLM支持
还有一个for
express ntlm
,它添加了一个Keep Alive
属性,可能会解决此问题,不幸的是,它未经广泛测试,首先需要验证。感谢您提供的信息。目前是否有人在测试PR?请随时测试它并在GitHub上给出反馈。完成@Fabio poloni