3 ms·
By my reading, the spec is not that clear about it. It does say that A user agent that wishes to authenticate itself with an origin server--usually, but not ne
by rapala 13y ago
By my reading, the spec is not that clear about it. It does say that
A user agent that wishes to authenticate itself with an origin server--usually, but not necessarily, after receiving a 401 (Unauthorized) --
implying, imo, that no prior 401 response is needed. On the other hand, the spec also says
A client SHOULD assume that all paths at or deeper than the depth of the last symbolic element in the path field of the Request-URI also are within the protection space specified by the Basic realm value of the current challenge. A client MAY preemptively send the corresponding Authorization header with requests for resources in that space without receipt of another challenge from the server.
which would imply that at least one 401 response should be received before sending credentials.
Of course the most important part of the spec is this:
The Basic authentication scheme is not a secure method of user authentication, nor does it in any way protect the entity, which is transmitted in cleartext across the physical network used as the carrier.
- mnarayan01 13y agoI don't think there's any ambiguity here...the first quote indicated that a client is absolutely allowed to send auth headers without receiving a 401 response. I read the second quote as giving client implementers a suggestion on when they should automatically send the auth headers, without actually requiring them to do so.
- cobralibre 13y agoI agree, and the practice of sending an Authorization header without first receiving a challenge is common enough that there's a phrase for it: preemptive authentication. See, for example, the Apache HttpClient documentation: http://hc.apache.org/httpclient-legacy/authentication.html#Preemptive_Authentication http://hc.apache.org/httpclient-legacy/authentication.html#P...