This guide shows how to build multi-tenancy with AccessPolicy
Aidbox stores all the tenants in a single database and serves number of them at once. It obtains tenant-id from each request and returns the data belonging to the tenant.
Key concepts
All resources have to be created with the tenant-id
tenant id is stored within the identifier attribute at the resource
Access policies require tenant-id parameter in each request
Multi-tenancy setup and requests example
Add Client
There are several ways to create client. We use the simplest one to do it: Basic Auth.
PUT /Client/org1Accept:text/yamlContent-Type:text/yamlid:org1secret:secretgrant_types: - basic
Add org-1 tenant resource
Create patient providing it's tenant-id in the identifier property.
PUT /Patient/test-patient-1Content-Type:text/yamlid:test-patient-1identifier:- system:tenantIdvalue:org1name:- given: - Johngender:male
Define AccessPolicy for multi-tenancy
Create access policy to ensure tenant-id is provided in all requests.