-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider setting 403 Forbidden on failed authBasic() #49
Comments
Unfortunately, I just realized my example has the negative effect of always setting |
You're right! Shouldn't be hard to implement. I'll do this by the end of this week =) |
I've reconsidered this after reading the RFC2616 again. Section 10.4.2 says (about 401):
Section 10.4.4 also says that (about 403):
I'm more towards returning 401 again on failure instead of 403. What do you guys think? @ramsey @augustohp |
Yes, I think 401 would be the correct return code. Here is how I did it.
|
Actually 401 needs to be the return code if authentication was tried and not successful. If authentication was not even tried, than perhaps should be left to the application developer like what ramsey suggested in the initial post, but maybe the expected behavior by the application developer is to end up at 403? Not sure how to implement that on AuthBasic.php. |
I'm switching my original request and agreeing with everyone that the return code should be 401, rather than 403, for failed authentication. As @mta59066 has suggested, I've changed my own code to return 401 and WWW-Authentication headers. |
Does this mean the issue is resolved and we can close it? If not does anyone care to roll a patch and make a pull request, please. If AuthBasic is in need of some TLC lets do that. |
The issue wasn't resolved, so I quickly created a patch and issued a pull request. :-) |
Awesome Tx! Will have a look see... you rock! =) |
Consider the following code example using the
authBasic()
routine:When I query this without providing basic auth headers, I get the correct
401 Authorization Required
response that I expect:However, if I do provide authentication headers, but the username and password are incorrect, causing the
authBasic()
routine to returnfalse
, then I get back a200 OK
response with no content.There is no security concern here, since you are properly blocking the client from receiving the content, but the
200 OK
doesn't seem appropriate. Perhaps a403 Forbidden
is more appropriate by default, or we can continue to leave it up to the application developer.Here's an example of how I'm accomplishing this right now:
The text was updated successfully, but these errors were encountered: