Node.js NTLM HTTP 身份验证,如何处理 3 种类型
我正在尝试让 NTLM 身份验证与 Node.js 一起工作。我一直在读这个( http://davenport.sourceforge.net/ntlm.html#theNtlmMessageHeaderLayout )。我发送标头并获得 Base64 身份验证标头。
我尝试通过使用 Base64 编码创建一个新的缓冲区,然后调用 toString('utf8')
将其从 Base64 转换为 UTF8,它返回一个类似
NTLMSSP\u0000\u0001\u0000\u0000 的字符串\u0000\u0007�\b�\u0000
这就是我需要帮助的地方。我知道 NTLMSSP\u0000 是空终止签名,但是其余的应该表示什么,但对我来说这只是垃圾。它是 unicode 字符,但我该如何从中获取实际数据呢?我可能错误地转换了它,这可能会增加我的麻烦,但我希望有人可以提供帮助。
I'm trying to get NTLM Authentication working w/ Node.js. I've been reading this ( http://davenport.sourceforge.net/ntlm.html#theNtlmMessageHeaderLayout ). I send the header and get a Base64 authentication header.
I tried converting it from Base64 to UTF8 by making a new Buffer with base64 encoding and then calling toString('utf8')
which returns a string something like
NTLMSSP\u0000\u0001\u0000\u0000\u0000\u0007�\b�\u0000
This is where I need help. I understand the NTLMSSP\u0000 is the null terminated signature, but and what the rest is supposed to indicate, but to me it's just garbage. It's unicode characters, but how am I supposed to get actual data out of that? I may be converting it incorrectly, which may be adding to my troubles, but I'm hoping someone can help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看看 http://www.innovation.ch/personal/ronald/ntlm.html
您收到的是 Type-2 消息。这些页面以非常实用的方式解释了它。您必须提取服务器质询(随机数)和服务器标志。
我刚刚为 node.js 实现了一个模块来做到这一点: https://github.com/SamDecrock /节点-http-ntlm
Have a look at http://www.innovation.ch/personal/ronald/ntlm.html
What you receive is a Type-2 Message. The pages explains it in a very practical way. You have to extract the server challenge (nonce) and the server flags.
I just implemented a module for node.js to do just that: https://github.com/SamDecrock/node-http-ntlm
你看过NTLMAPS吗?
您也许可以通过将其用作代理服务器来解决您的问题,但如果您确实想在 Javascript 中实现 NTLM 身份验证,那么 NTLMAPS 提供了大量可供研究的工作代码。
Have you looked at NTLMAPS?
You may be able to solve your problem by using it as a proxy server, but if you really want to implement NTLM auth in Javascript, then NTLMAPS provides lots of working code to study.
Sam 发布了我所见过的最好的资源来了解正在发生的事情。
GitHub 上的 jclulow 似乎已经在他构建的 Samba 库中实现了它。
看看这里:
https://github.com/jclulow/node-smbhash
在 lib\ntlm.js 下,您可以看到他如何处理响应。
Sam posted the best resource I've seen for understanding what's going on.
jclulow on GitHub seems to have implemented it in a Samba library he built.
Take a look here:
https://github.com/jclulow/node-smbhash
under lib\ntlm.js you can see how he's handled the responses.
几个月前,我使用 javascript ntlm.js 构建了客户端。也许这可以帮助你们相处。它基于文档 @ Innovation.ch 和 Microsoft 自己的官方文档(请参阅 github 页面上的参考资料)。
I've built client a couple of months ago using javascript, ntlm.js. Maybe that can help you get along. It was based on the documentation @ innovation.ch and Microsofts own official documentation (see the references on the github page).