1

我正在尝试使用纯 Javascript 对 Jazz 服务器进行身份验证。我应该能够在https://myserver:9444/qm/authenticated/j_security_check?j_username=foo&j_password=bar. (在 POST 上也有相同的行为)

这在 Ff 插件海报中工作正常 - 如果我提供一个虚拟的用户代理标头。但是,在我正在编写的 JS 代码中(使用 dojo.xhrGet),我收到了 400 - bad request,主要是因为 heager 说的是 Chrome,响应 HTML 说明 -You have followed a direct link to log in to a Jazz server. This page has been presented to ensure that a malicious website cannot use cleverly crafted content to circumvent security. If you would like to log in to the server, please use the link below.

我遇到的问题是 - 我无法覆盖 dojo.xhrGet 中的用户代理标头,因为它是受保护的标头,Refused to set unsafe header "user-agent如果您尝试使用“api”之类的值覆盖它,您会得到一个。

我如何绕过这个第 22 条问题?

4

1 回答 1

1

您不能User-Agent更改XMLHttpRequest. 请参阅这个 SO问题

如果您想对 Jazz 服务器进行身份验证,您应该使用dojo.xhrPost将 HTTP POST 请求发送到表单身份验证 url。

dojo.xhrPost({
   url: '/qm/authenticated/j_security_check',
   data: {
     j_username: 'foo',
     j_password: 'bar'
   }
})
于 2013-09-23T23:20:01.287 回答