[英]How to read HTTP protocol headers when using Angular 2?
My Angular 2 application is behind a reverse proxy that add HTTP headers like: 我的Angular 2应用程序位于反向代理后面,该反向代理添加HTTP标头,例如:
Auth-User: somebody
Auth-Groups: something, something, ...
How can I read these values from my Angular 2 application? 如何从Angular 2应用程序中读取这些值? Note that I am not:
请注意,我不是:
Basically I need to support a SSO scheme based on trusted HTTP headers from the very first time a browser hits my server. 基本上,从浏览器第一次访问我的服务器时,我就需要支持基于受信任HTTP标头的SSO方案。
Any ideas? 有任何想法吗?
Lars 拉尔斯
I realize that it cannot be done directly. 我意识到这无法直接完成。 Angular is client oriented and heavily sandboxed by the browser, so it is only the server that is able to access the necessary headers.
Angular是面向客户端的,并被浏览器大量沙箱化,因此只有服务器才能访问必要的标头。 What I have come up with is:
我想出的是:
So instead of doing a basic authentication scheme like most examples/tutorials use, the solution is just getting the headers values wrapped in a service call. 因此,解决方案不是像大多数示例/教程一样使用基本的身份验证方案,而是仅将标头值包装在服务调用中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.