views:

422

answers:

2

Using Basic Authentication, if the user has already logged in, the browser will include the username/password in the http request in the succeeding http requests ONLY IF it receives a 401 response containing an authentication challenge. Username/password is passed via Authorization header.

Is there a way to force the browser to always include the Authorization header once the user has logged in?

The reason I'm asking for this is that I have a CGI application (separate from the main CGI app that serves my dynamic pages) that should use the Authorization info if present but should not prompt for it if it's not present.

Thanks.

A: 

if the user has already logged in, the browser will include the username/password in the http request in the succeeding http requests ONLY IF it receives a 401 response containing an authentication challenge

This is not the behaviour I see in web browsers; once the browser has received a 401, it always includes the authorization after that. Can you perhaps provide more detail on how to reproduce the problem?

Curt Sampson
That's actually what I was asking for. The browser would have to receive a 401 response first before it provides the authorization header. I'm asking for a way to have the authorization header included even if the browser hasn't received a 401 response.
teriz
I see. That's a bit of a tricky problem. Can you tell us what problem would be solved by making this happen, and perhaps we can attack it from another direction?
Curt Sampson
A: 

One solution would be to expose one handler of your CGI app, that would generate an HTML page that would do an AJAX call, prompting the 401 that would then be responded to by the browser. Would that make sense?