Description
Liberator maps :authorized?
to the 401 Unauthorized
response, I believe this is wrong according the IETF description of this response code here:
3.1. 401 Unauthorized
The 401 (Unauthorized) status code indicates that the request has not
been applied because it lacks valid authentication credentials for
the target resource. The server generating a 401 response MUST send
a WWW-Authenticate header field (Section 4.1) containing at least one
challenge applicable to the target resource.
This should rather be :authenticated?
and be handled before the contents of the requests are inspected (i.e. before :malformed?
/400 Bad Request
).
Instead :authorized?
should replace :allowed?
and map to the 403 Forbidden
response, again this is the description according to the IETF here:
The 403 (Forbidden) status code indicates that the server understood
the request but refuses to authorize it. A server that wishes to
make public why the request has been forbidden can describe that
reason in the response payload (if any).
I can see why you would not want to implement this change at this point, but I wanted to see if there was a reason behind this and to mark it in case other users come across this in the future.
It's reasonable to continue using the framework transposing the meaning of these two handlers (:authorized?
=> :authenticated?
, :allowed?
=> :authorized?
) and accept that the body will be deserialized before a request is authenticated.
An alternative flow diagram illustrating what I believe is the correct order can be seen here.