-
Notifications
You must be signed in to change notification settings - Fork 49
Multi tenant domain model
Michael J. Giarlo edited this page Jun 16, 2017
·
2 revisions
In Hyku, each tenant is managed by an Account
. Account
segments the application data as follows:
- First, a unique identifier for the tenant (a random UUID) is generated
- The
Apartment
gem is used to segment the application database. In the PostgreSQL database, this segmentation occurs via database schemas. So, each Hyku tenant stores its data in its own database schema. (NOTE: Apartment also calls these segments "tenants". But, in Hyku, a tenant encompasses a bit more, as you will see below.)- It is worth noting that most models become scoped to an
Apartment
tenant (i.e. they apply to a specific tenant's database schema). However,Account
is a global model, as it manages the tenant.
- It is worth noting that most models become scoped to an
- A Solr Collection is created specific to the tenant (named with the tenant UUID). All objects in this tenant will be indexed into that collection.
- A Fedora Container is created specific to the tenant (named with the tenant UUID). All objects in this tenant will be stored in this container.
- A Redis namespace is created specific to the tenant (named with the tenant UUID).
- A
Site
is created on the tenant. TheSite
corresponds to this tenant's Hyku application (and is configured to use the defined database schema, Solr collection, Fedora container, etc).Site
is a singleton that we use to effectively namespace, e.g.,application_name
values.
Other models to be aware of:
- Application users are managed by the
User
model. EachUser
has one or moreRoles
.Users
are defined within a tenant scope (usingApartment
). So, if a user has a login for multiple Sites, those logins are stored separately (and may have different passwords, etc). - Some
Roles
are scoped toSites
; some aren't. There is a many-to-many relationship betweenRoles
andUsers
. We currently have twoRoles
defined: Site admins and SuperAdmins. SuperAdmins can create/manage tenants, while a Site admin is only an admin in a specific tenant. -
Abilities
useRoles
to make authorization decisions onResources
(terminology from the rolify gem).