Restrict operations on resource type
Create a patient
POST /fhir/Patient
id: pt-1
resourceType: Patient
name:
- given:
- John
Create an access policy
Create an access policy which allows only FhirRead operation on Patient.
POST /fhir/AccessPolicy
engine: matcho
matcho:
operation:
id: FhirRead
params:
resource/type: Patient
Try it
Create
We won't be able to create new patient because we're not allowed to use FhirCreate operation
POST /fhir/Patient
id: pt-2
resourceType: Patient
name:
- given:
- Jane
resourceType: OperationOutcome
id: forbidden
text:
status: generated
div: Forbidden
issue:
- severity: fatal
code: forbidden
diagnostics: Forbidden
Read
FhirRead operation works as expected and you are able to read previously created patient
GET /fhir/Patient/pt-1
name:
- given: [John]
id: pt-1
resourceType: Patient
What's going on here
When you make a query
GET /fhir/{resource-type}/{resource-id}
Aidbox router stores data in the request object:
- Reference to the
FhirReadoperation in theoperationproperty. - Resource type
Patientfrom the url to theparams.resource/typeproperty.
Access policy engine evaluates request object. And here it checks that operation.id property equals FhirRead.
You can inspect request object using __debug query parameter.