if you have a REST API
that is hypermedia-driven
(HATEOAS) you can easily change a client's behavior by including or omitting links in the response (_links
). That enables a client to completely forget about testing permissions for the operations that are possible in the current state of a resource
(the link to the operation is present or not).
Additionally you can leave out properties in the response if the current user doesn't have permission to see it.
That way authorization is done entirely on the server (and controls actions and properties that are eligible to execute/view).
But what if I want to a have a read-only
property? It is no problem for the REST
API
to ignore the property if it is present in the request (_POST_
OR _PUT_
). it just won't get saved. But how can a client distinguish between write and read-only properties to present the user appropriate controls (like a disabled input field in HTML
)?
The goal is to never ever have the client request
a user's permissions, but to have a completely resource driven client/frontend
.
Any help is greatly appreciated :-)