Sample Multi-tenant application with a multi-tenancy strategy implemented as a separate database per tenant and one main database which keeps the general tenants information.
After adding a new tenant - a database and a datasource will be created automatically (at runtime - no app/server restart needed)
curl --location --request GET 'http://localhost:8080/admin/tenants'
curl --location --request POST 'http://localhost:8080/admin/tenants' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "tenant3"
}'
curl --location --request GET 'http://localhost:8080/tenant/app/settings' \
--header 'X-TenantID: tenant3'
curl --location --request POST 'http://localhost:8080/tenant/app/settings' \
--header 'X-TenantID: tenant3' \
--header 'Content-Type: application/json' \
--data-raw '{
"key": "theme",
"value": "light",
"type": "String"
}'
- Add Liquibase migrations
- Exception handling
- Security
/admin/*
should be accessible only for users with a role/groupADMIN
and the requests should not haveX-TenantID
header/tenant/*
should be accessible only for users with a role/groupTENANT
and the requests should haveX-TenantID
header
- Tenants DB connections management
- Tenant removal - drop db/ remove DataSource