Skip to content
This repository has been archived by the owner on Sep 12, 2021. It is now read-only.

Normalize FORBIDDEN vs UNAUTHORIZED responses #35

Merged
merged 1 commit into from Jan 19, 2014

Conversation

fernandoacorreia
Copy link
Contributor

I believe in some situations the code is returning status code FORBIDDEN when it should be UNAUTHORIZED.

I'll review the code and propose a fix.

The name of these status codes can be misleading. UNAUTHORIZED is related to authentication and FORBIDDEN is related to authorization.

For reference reviewing this issue:

401 Unauthorized means "The request requires user authentication." The client MAY repeat the request with a suitable Authorization header field. It's a temporary condition.

403 Forbidden means "The server is refusing to fulfill the request." Authorization will not help and the request SHOULD NOT be repeated. It's a permanent condition.

In summary, a 401 Unauthorized response should be used for missing or bad authentication, and a 403 Forbidden response should be used afterwards, when the user is authenticated but isn’t authorized to perform the requested operation on the given resource.

@akkie
Copy link
Contributor

akkie commented Jan 16, 2014

Thanks for clarification. I agree, we should fix this.

akkie added a commit that referenced this pull request Jan 19, 2014
Normalize FORBIDDEN vs UNAUTHORIZED responses
@akkie akkie merged commit 9f473b3 into mohiva:master Jan 19, 2014
@akkie
Copy link
Contributor

akkie commented Jan 19, 2014

Thanks, merged.

@akkie
Copy link
Contributor

akkie commented Jan 19, 2014

How did you create a pull request from the previous created issue?

@fernandoacorreia
Copy link
Contributor Author

With hub:

$ hub pull-request -b USERNAME_OF_UPSTREAM_OWNER:UPSTREAM_BRANCH -h YOUR_USERNAME:YOUR_BRANCH URL_TO_ISSUE

http://stackoverflow.com/a/7841960/376366

@fernandoacorreia fernandoacorreia deleted the rectify-401-403 branch January 19, 2014 11:50
@akkie
Copy link
Contributor

akkie commented Jan 19, 2014

Many thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants