简体   繁体   English

使用Angular2的NTLM身份验证

[英]NTLM authentication using Angular2

In my client web application, I need to authenticate with the server using ntlm protocol. 在我的客户端Web应用程序中,我需要使用ntlm协议向服务器进行身份验证。 While using Angular1, with the $http service get request, the browsers (chrome, edge) were doing all the 3 steps of the NTLM authentication by prompting user for username/password. 在使用Angular1时,通过$ http服务获取请求,浏览器(chrome,edge)通过提示用户输入用户名/密码来执行NTLM身份验证的所有3个步骤。

However, with Angular2, using the http service that comes with Angular2, the browser (chrome,edge) just return 401 and do not do the subsequent steps (they do not even prompt the user for credentials). 但是,对于Angular2,使用Angular2随附的http服务,浏览器(chrome,edge)仅返回401,并且不执行后续步骤(它们甚至不提示用户输入凭据)。

How do I make browser do the ntlm authentication for me while using Angular2 ? 在使用Angular2时,如何使浏览器为我执行ntlm身份验证? Please do not suggest the ntlm javascript library. 请不要建议ntlm javascript库。 I'm new to StackOverflow. 我是StackOverflow的新手。 If I haven't given sufficient info or repeated the question, sorry about that. 如果我没有提供足够的信息或重复了问题,对此表示抱歉。

Thanks in Advance. 提前致谢。

"withCredentials" needs to set true in headers to make it work. “ withCredentials”需要在标头中设置为true才能起作用。 My code is working now. 我的代码正在运行。

let options = new RequestOptions({ headers: headers, withCredentials: true });

I don't believe the problem is with NTLM or in your coding efforts. 我不认为问题出在NTLM或您的编码工作上。 According to Anton Bessonov, a very reputable SO community member, some modules in Angular2 are just not production-ready yet, while Angular1 is a very stable code release, and my advise is to stick with Angular1 that for the foreseeable future. 根据非常有名的SO社区成员Anton Bessonov的说法,Angular2中的某些模块还没有投入生产,而Angular1是一个非常稳定的代码版本,我的建议是在可预见的将来坚持使用Angular1。 Ref: angular 1 vs angular 2 for new project 参考: 新项目的角度1与角度2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM