Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
docs: add multi-tenancy docs (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
carvantes committed Aug 18, 2021
1 parent fc60522 commit 7d6bc44
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ git clone https://github.com/awslabs/fhir-works-on-aws-deployment.git

If you intend to use FHIR Implementation Guides read the [Using Implementation Guides](./USING_IMPLEMENTATION_GUIDES.md) documentation first.

If you intend to do a multi-tenant deployment read the [Using Multi-Tenancy](./USING_MULTI_TENANCY.md) documentation first.

### Post installation

After your installation of FHIR Works on AWS you will need to update your OAuth2 authorization server to set the FHIR Works API Gateway endpoint as the audience of the access token.
Expand Down
52 changes: 52 additions & 0 deletions USING_MULTI_TENANCY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Multi-Tenancy

Multi-tenancy allows a single `fhir-works-on-aws` stack to serve as multiple FHIR servers for different tenants.

`fhir-works-on-aws` uses a pooled infrastructure model for multi-tenancy. This means that all tenants share the
same infrastructure (DynamoDB tables, S3 Buckets, Elasticsearch cluster, etc.), but the data
is logically partitioned to ensure that tenants are prevented from accessing another tenant’s resources.

## Enabling multi-tenancy

Use the `enableMultiTenancy` option when deploying the stack:

```bash
serverless deploy --enableMultiTenancy true
```

**Note:** Updating an existing (single-tenant) stack to enable multi-tenancy is a breaking change. Multi-tenant
deployments use a different data partitioning strategy that renders the old, single-tenant, data inaccessible.
If you wish to switch from single-tenant to a multi-tenant model, it is recommended to create a new multi-tenant stack
and then migrate the data from the old stack. Switching from multi-tenant to a single-tenant model is also a breaking change.

## Tenant identifiers

Tenants are identified by a tenant Id in the auth token. A tenant Id is a string that can contain alphanumeric characters,
dashes, and underscores and have a maximum length of 64 characters.

There are 2 ways to include a tenant Id in the auth token:

1. Add the tenant Id in a custom claim. This is the recommended approach.
The default configuration adds the tenant Id on the `tenantId` claim

1. Encode the tenant Id in the `aud` claim by providing an URL that matches `<baseUrl>/tenant/<tenantId>`.
This can be useful when using an IDP that does not support custom claims.

If a token has a tenant Id in a custom claim and in the aud claim, then both claims must have the same tenant Id value,
otherwise an Unauthorized error is thrown.

## Additional Configuration

Additional configuration values can be set on [config.ts](https://github.com/awslabs/fhir-works-on-aws-deployment/blob/mainline/src/config.ts)

- `enableMultiTenancy`: Whether or not to enable multi-tenancy.
- `useTenantSpecificUrl`: When enabled, `/tenant/<tenantId>/` is appended to the FHIR server url.

e.g. A client with `tennatId=tenantA` would use the following url to search for Patients:
```
GET <serverUrl>/tenant/<tenantId>/Patient
GET https://1234567890.execute-api.us-west-2.amazonaws.com/dev/tenant/tenantA/Patient
```
Enabling this setting is useful to give each tenant a unique FHIR server base URL.

- `tenantIdClaimPath`: Path to the tenant Id claim in the auth token JSON. Defaults to `tenantId`

0 comments on commit 7d6bc44

Please sign in to comment.