http://user:pass@host.com 身份验证如何工作?
谁能解释一下http://user:[电子邮件受保护] 身份验证有效吗?浏览器是否发送使用 Base-64 编码的 user:pass
的 Authorization
标头?
我在 Chrome 开发者工具中打开了 Net 控制台,当我发出诸如 http://user:[电子邮件受保护]
我愿意没有看到添加的 Authorization
标头。
我真的很好奇,如果我在 URL 前面使用 user:pass@
,浏览器如何发送密码。
Can anyone explain how http://user:[email protected] authentication works? Does the browser send the Authorization
header with user:pass
being base-64 encoded?
I opened the Net console in Chrome developer tools and when I do request such as http://user:[email protected]
I do not see Authorization
header being added.
I am really curious to how the browser sends the password in case I use user:pass@
in front of a URL.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要检查标头,您需要针对需要身份验证的服务器进行测试。在服务器请求之前,客户端不会发送任何“Authorization”标头,因为客户端不知道服务器需要什么身份验证方法(基本或摘要)。
HTTP 身份验证通过两个请求完成:
首先,发送不带任何
Authorization
标头的请求。然后,服务器使用
WWW-Authenticate
进行响应,告诉客户端如何进行身份验证。这包括领域名称和身份验证方法(同样,这是基本的或摘要的),然后客户端发送带有附加
Authorization
标头的新请求。对于基本身份验证,此标头只是user:pass
base64 编码,正如您所说:现在密码在传输过程中可见,除非您使用 https。更好的选择是摘要式身份验证,其中
WWW-Authenticate
和Authorization
在 wikipedia 文章 中得到了最好的解释。 :)To inspect headers, you need to test against a server that requires authentication. The client will not send any
Authorization
header until the server asks for it since the client won't know what authentication method the server requires (basic or digest).HTTP authentication is done in two requests:
First, a request without any
Authorization
header is sent.The server then responds with a
WWW-Authenticate
that tells the client how to authenticate. This includes a realm name and an authentication method (again, this is either basic or digest)The client then sends a new request with an additional
Authorization
header. In the case of basic authentication, this header is justuser:pass
base64 encoded, just as you are saying:Now the password is visible in transit, unless you are using https. A better option is digest authentication, where the contents of both
WWW-Authenticate
andAuthorization
are best explained by the wikipedia article. :)