我可能遗漏了一些明显的东西......但是
我正在尝试使用 greasemonkey 插件增强 native 颠覆 http 访问。目前,我正在使用 CGI 脚本来运行 PROPFIND 等。这会破坏安全性,尽管它确实有效。
我已经从 http://debris.demon.nl/projects/davclient.js/ 下载了一个 Javascript DAV 客户端,它可以做我想做的一切。 .假设我可以使用已经提供的用户凭据,我应该能够使用具有正确安全性的 javascript 获取扩展的颠覆信息。
我们在颠覆服务器上运行基本身份验证,我不知道如何让这个库中的 xmlHttpRequest 继承预先存在的浏览器身份验证细节。 xmlHttpRequest 返回 401,尽管调用页面已通过身份验证并且位于同一域中。
最佳答案
您可以使用 .setRequestHeader(header, value)
手动指定 Authorization
header .
根据 the spec :
If the user agent supports HTTP Authentication and
Authorization
is not in the list of author request headers [set bysetRequestHeader
], it should consider requests originating from theXMLHttpRequest
object to be part of the protection space that includes the accessed URIs and sendAuthorization
headers and handle401 Unauthorized
requests appropriately.
这似乎意味着如果用户已经为资源提供了身份验证凭据,XHR 将自动使用它们。
关于javascript - xmlHttpRequest可以访问Firefox中的授权 header 吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15836357/