Closed eevaturkka closed 7 years ago
Interesting....
Yes, I would say this is an issue. Let me try and get a unit test written.
Ok, reproduced. I will check in a fix a bit later.
I'm inclined to say that if a resource is being updated from A to B, the client needs to have write permission for both A and B. That seems like the easiest way to fix this.
Still using Hapi 2.4
We have created scopes like:
builder.allow("read:" + scope).read().resourcesOfType(Observation.class).inCompartment("Patient", userIdPatientId);
and
builder.write("write:" + scope).write().resourcesOfType(Observation.class).inCompartment("Patient", userIdPatientId);
Lets say there is an Observation 1 with patient A (44a12254-b28d-42f9-8bec-4a468473ef9f) that's been saved with Access token with Patient A as the resource owner. Now it is possible for Patient B to update Observation 1 to with permissions from her access token if the subject of the resource in the update request is Patient B (21bb8e2a-673e-42f0-8843-ac90d18d8222).
Shouldn't there be also a check in the update operation that the resource being updated is within the given rules? Are we missing some rule here?
POSTing first version of a resource and reading a resource with GET work correctly with the rules here.
POST Patient 44a12254-b28d-42f9-8bec-4a468473ef9f
response:
PUT with Patient B (21bb8e2a-673e-42f0-8843-ac90d18d8222)
response for the put with patient B.