Closed asbjornu closed 5 years ago
ISTM that the phrase "authorize it" in the first sentence of 6.5.3 is the root of the issue. I note that 2616 used "fulfill it" instead; we should dig around and see if that was an intentional change.
I agree "authorize it" is the root issue, but think it's exacerbated by the following paragraph. It would be good to clarify the entire section to make it obvious that the presence of an Authorization
header doesn't require the semantics to change.
Discussed in Montreal; ok to change.
The change from “authorize” to “fulfill” helps to resolve the ambiguity, although I would like to see a MAY
in the following paragraph:
If authentication credentials were provided in the request, the server
MAY
consider them insufficient to grant access. The client SHOULD NOT automatically repeat the request with the same credentials. The client MAY repeat the request with new or different credentials.
I don't think a "MAY" helps here.
The current text is:
If authentication credentials were provided in the request, the server considers them insufficient to grant access.
That's a statement of fact. If the credentials would have been sufficient, there wouldn't be an error. (It does not necessarily imply that things would have worked with different credentials).
I think that’s exactly what the current text implies: That sufficient credentials would have lead to a successful request, regardless of the state of the resource.
If we take the example from RFC 7807, there is nothing that a change of credentials can do to make the request succeed — the credit is out regardless of the authorisation.
Question: this change makes 429 a specialization of 403, right?
But that proposed "MAY" isn't permissive. This is a statement, not necessarily of fact, but of one likely possibility. Perhaps "the server considers" => "the server might consider"
In its current wording, I interpret RFC 7231 §6.5.3 to allow
403 Forbidden
to be used in the following two situations:This ambiguity is established in the following paragraph:
The ambiguity is somewhat lifted (but not entirely) by the last sentence:
However, I believe the ambiguity exists and causes a lot of developers to believe that
403 Forbidden
is only applicable to authorization errors. I think the wording in the previous paragraph:…the example given in RFC 7807:
…and the wording in RFC 7807 §4:
…as well as existing practice establishes that
403 Forbidden
is the correct status code to respond with when the requested operation is not allowed in the current state of the application (use-case 1 above), regardless of theAuthorization
header provided.Introducing the ambiguity of
403
only being applicable to the provided authorization when authorization is available makes the status code harder to reason about and therefore harder to use in practice. Would it be possible to remove this ambiguity somehow? Here's some suggested wording: