On Jun 1, 10:43 pm, Rebornspirit <
maarten.vold...@gmail.com> wrote:
> When I set the user / password I don't see anything being added on the
> Authorization request header ... strange, when I put them manually
> using setHeader it works fine. Any idea what is going on?
> The strange thing is that when I add a header manually, let's say with
> the wrong user / password AND I set the user and password manually
> than the following is happening (I'm using Acegi basic authentication
> filters here)
> - basic authentication filter gets called with in the auth header that
> wrong user / password
> - right after a second call to that authentication filter is happening
> BUT this time that same Auth header contains the user / password I set
> manually, so the correct ones??? what is happening here? And why isn't
> this auth header filled in when I only set user / password and not the
> header?
>
> I'm confused :-D
The browser first check the server expects credentials (and how:
Basic, Digest, etc.); because you explicitly set the Authorization
header, it is sent as well. Your filter sends a 401, so the browser
knows that the server expects credentials and now knows how to send
them too.
If the browser was sending credentials without this first check, it
would send them with Basic auth scheme (Digest requires a nonce issued
by the server), so the password is sent "in the clear"; this would be
a huge security hole.