For AI agents: the documentation index is at /docs/aidbox/llms.txt. A Markdown version of this page is available at /docs/aidbox/tutorials/security-access-control-tutorials/restrict-operations-on-resource-type.md or by requesting it with the Accept: text/markdown header.
Aidbox Docs

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 FhirRead operation in the operation property.
  • Resource type Patient from the url to the params.resource/type property.

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.

Last updated: