HTTP 身份验证何时发生?其中之一是使用 http://peter:mypassword@www.somesite.com 吗?
似乎有 2 个 HTTP 身份验证: 基本访问身份验证 和 摘要式访问认证
所以我认为一般来说,用户尝试访问一个URL,Web服务器返回401 Unauthorized,然后浏览器返回 弹出一个应用程序窗口,询问用户名和密码,然后在 HTTP 标头中设置凭据,然后再次发送 HTTP 请求。
http://peter:[电子邮件]怎么样;受保护]?那是不是应该不等401回来而是提前提供用户名和密码呢? 不知怎的,我尝试了 http://peter:[email protected] 或 yahoo,但在 Fiddler 内部(用于监控网络流量),我在 HTTP 请求中没有看到任何凭据信息?
There seems to be 2 HTTP Authentication: Basic access authentication and Digest access authentication
So I think in general, a user tries to access a URL, and the web server returns 401 Unauthorized, and then the browser
pops up an app window, asking for username and password, and then set the credentials in the HTTP headers then sends the HTTP request again.
What about http://peter:[email protected] ? Is that supposed to not wait for the 401 to come back but provide the username and password in advance?
Some how, I tried http://peter:[email protected] or yahoo but inside of Fiddler (to monitor net traffic), I don't see any credential info in the HTTP request?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您仍然需要在服务器端发送 401。 user:pass@host 只是为了避免显示登录对话框。
如果您考虑一下,这是有道理的,因为如果您不发送带有解释要使用哪种方法的标头的 401,则客户端不知道如何格式化凭据。
(实际上有很多方案,不仅仅是 Basic 和 Digest。)
You still need to send the 401 on the server side. The user:pass@host is just a convenience to avoid displaying the login dialog.
If you think about it, this makes sense, because if you don't send the 401 with the header explaining which method to use, the client doesn't know how to format the credentials.
(There are actually any number of schemes, not just Basic and Digest.)
为了对其有所了解,有一个 Railscast 讨论了 HTTP 基本身份验证并将其添加到 Rails 项目以及它在浏览器上的外观: http://railscasts.com/episodes/82-http-basic-authentication
For some understanding of it, there is a Railscast that talks about HTTP Basic Authentication and adding it to a Rails project and how it looks like on a browser: http://railscasts.com/episodes/82-http-basic-authentication