我是否可以强制Apache不包括失败的HTTP Basic Auth的WWW-Authenticate标头?

时间:2022-10-19 18:18:58

I'm using HTTP Basic Authentication with AJAX requests. Firefox 3 is a whiner and always displays a dialog box for failed credentials -- even though I don't want one.

我正在使用带有AJAX请求的HTTP基本身份验证。 Firefox 3是一个唠叨者,并且总是显示一个失败凭据的对话框 - 即使我不想要一个。

This question summarizes some of the browser and JS issues; you'll notice it's unresolved on the client side. Luckily, I have at least some freedom to change the server -- I can modify my .htaccess file.

这个问题总结了一些浏览器和JS问题;你会注意到它在客户端没有得到解决。幸运的是,我至少有一些*来更改服务器 - 我可以修改我的.htaccess文件。

Basically, whenever Firefox sees the WWW-Authenticate header, it tries to authenticate again. Can I suppress that header only for AJAX requests by modifying my .htaccess file? If so, how? I can pass a custom header in my XHR request if necessary.

基本上,每当Firefox看到WWW-Authenticate标头时,它都会尝试再次进行身份验证。我可以通过修改.htaccess文件来仅为AJAX请求抑制该标头吗?如果是这样,怎么样?如有必要,我可以在我的XHR请求中传递自定义标头。

Here's what it looks like currently:

这是目前的样子:

AuthType Basic
AuthUserFile /www/private/.htpasswd
AuthName "Private Collection"
require valid-user

1 个解决方案

#1


I faced a similar problem that I solved through a proxy written in nodejs. Perhaps this can help you: Write proxy/wrapper class for own service in jersey

我遇到了类似的问题,我通过nodejs编写的代理解决了这个问题。也许这可以帮到你:在泽西为自己的服务编写代理/包装类

#1


I faced a similar problem that I solved through a proxy written in nodejs. Perhaps this can help you: Write proxy/wrapper class for own service in jersey

我遇到了类似的问题,我通过nodejs编写的代理解决了这个问题。也许这可以帮到你:在泽西为自己的服务编写代理/包装类