Skip to content

Commit 3203b4f

Browse files
docs(tenant-management): update the readme
GH-109
1 parent f87f036 commit 3203b4f

File tree

5 files changed

+69
-50
lines changed

5 files changed

+69
-50
lines changed

services/subscription-service/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ $ [npm install | yarn add] @sourceloop/ctrl-plane-subscription-service
6262
// add Component for subscription-service
6363
this.component(SubscriptionServiceComponent);
6464
```
65+
- If you uses Sequelize as the ORM, make sure to use the Sequelize-compatible components,else use the respective default components.
66+
```ts
67+
this.component(SubscriptionSequelizeServiceComponent);
68+
```
6569
- Set up a [Loopback4 Datasource](https://loopback.io/doc/en/lb4/DataSource.html) with `dataSourceName` property set to
6670
`SubscriptionDB`. You can see an example datasource [here](#setting-up-a-datasource).
6771
- This component internally uses [FeatureToggleServiceComponent](https://www.npmjs.com/package/@sourceloop/feature-toggle-service) that requires a datasource binding with the name 'FeatureToggleDB'. Make sure to create a datasource for it.

services/tenant-management-service/README.md

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ $ [npm install | yarn add] @sourceloop/ctrl-plane-tenant-management-service
4242
// add Component for TenantManagementService
4343
this.component(TenantManagementServiceComponent);
4444
```
45-
45+
- If you uses Sequelize as the ORM, make sure to use the Sequelize-compatible components,else use the respective default components.
46+
```ts
47+
this.component(TenantManagementSequelizeServiceComponent);
48+
```
4649
This microservice uses [loopback4-authentication](https://www.npmjs.com/package/loopback4-authentication) and [@sourceloop/core](https://www.npmjs.com/package/@sourceloop/core) and that uses asymmetric token encryption and decryption by default for that setup please refer [their](https://www.npmjs.com/package/@sourceloop/authentication-service) documentation but if you wish to override and use symmetric encryption add the following to your `application.ts` file along with other config values.
4750

4851
```typecript
4952
this.bind(TenantManagementServiceBindings.Config).to({
50-
useCustomSequence:true,
53+
useSymmetricEncryption:true,
5154
});
5255
5356
```
@@ -66,14 +69,29 @@ this.bind(TenantManagementServiceBindings.Config).to({
6669
- The front end application first calls the `/leads/{id}/verify` which updates the validated status of the lead in the DB and returns a new JWT Token that can be used for subsequent calls
6770
- If the token is validated in the previous step, the UI should call the `/leads/{id}/tenants` endpoint with the necessary payload(as per swagger documentation).
6871
- This endpoint would onboard the tenant in the DB, and its success you should trigger the relevant events using the `/tenants/{id}/provision` endpoint.
69-
- The provisioning endpoint will invoke the publish method on the `EventConnector`. This connector's purpose is to provide a place for consumer to write the event publishing logic. And your custom service can be bound to the key `EventConnectorBinding` exported by the service.
72+
73+
## Direct Tenant Onboarding
74+
75+
In addition to the lead-based onboarding flow, a new tenant can also be onboarded directly without creating a lead first.
76+
This capability is designed specifically for control plane administrators, who can create and provision tenants directly through the management APIs.
77+
78+
To ensure security and operational control, only users with control plane admin privileges are allowed to perform direct tenant onboarding.
79+
Regular users or leads cannot bypass the standard lead creation and verification process.
80+
81+
To onboard a tenant directly, you should call the `/tenants` endpoint.
7082

7183
## Event Publishing
7284

7385
The service supports pluggable event strategies — EventBridge, SQS, and BullMQ — through the loopback4-message-bus-connector.
7486

7587
You can publish provisioning or deployment events by injecting a Producer for your desired message bus strategy.
7688

89+
To enable these strategies, bind the following component in your application:
90+
```ts
91+
this.component(EventStreamConnectorComponent);
92+
```
93+
Once configured, you can publish provisioning or deployment events by injecting a Producer for the desired message bus strategy.
94+
7795
```ts
7896
import {producer, Producer, QueueType} from 'loopback4-message-bus-connector';
7997

@@ -151,6 +169,47 @@ app
151169
.bind(TenantManagementServiceBindings.IDP_AUTH0)
152170
.toProvider(Auth0IdpProvider);
153171
```
172+
### Keycloak IdP Provider
173+
174+
The Keycloak IdP Provider automatically sets up and configures all the required Keycloak resources for a new tenant during onboarding.
175+
176+
It eliminates manual setup and ensures each tenant has a secure, isolated identity environment.
177+
178+
When a new tenant is provisioned, the provider automatically:
179+
- Creates a Realm in Keycloak for that tenant.
180+
(Each tenant gets its own isolated authentication space.)
181+
182+
- Configures SMTP (Email) settings in the realm using AWS SES for password reset and notification emails.
183+
184+
- Creates a Client inside the realm for the tenant’s application with the correct redirect URIs and credentials.
185+
186+
- Creates an Admin User for the tenant with a temporary password and triggers a password reset email.
187+
188+
- Returns the admin user’s ID (authId) after successful setup.
189+
190+
This setup ensures that every tenant has a ready-to-use Keycloak environment, complete with its own realm, client, and admin user, enabling secure login and user management from day one.
191+
192+
### Auth0 IdP Provider
193+
194+
The Auth0 IdP Provider automates the Auth0 setup required for a tenant during onboarding. It creates the Auth0 organization, provisions an initial admin user, and adds that user to the organization — all based on tenant details and stored tenant configuration.
195+
196+
When a tenant is provisioned, the provider will:
197+
198+
- Create (or reuse) an Auth0 Organization for the tenant.
199+
200+
For PREMIUM tenants a dedicated organization is created per tenant. For pooled plans, tenants are grouped under a shared organization named after the plan tier. This ensures correct isolation or pooling based on your plan model.
201+
202+
- Apply branding and connection settings to the organization using the tenant configuration (logo, colors, enabled connections, etc.).
203+
204+
This makes tenant login pages and connections (social/database) behave and look as configured for that tenant.
205+
206+
- Create an Admin User for the tenant using the tenant contact details and a generated temporary password.
207+
208+
The password is generated securely and the admin is expected to verify or change it through Auth0 flows (no password is persisted in plain text).
209+
210+
- Add the admin user as a member of the Auth0 Organization so they can manage users, connections, and settings for that tenant.
211+
212+
- Return the Auth0 user ID (authId) on success so the control plane can reference the identity for audits or future operations.
154213

155214
## Webhook Integration
156215

@@ -572,7 +631,7 @@ The migrations required for this service can be copied from the service. You can
572631

573632
## Database Schema
574633

575-
![alt text](./docs/tenants.png)
634+
![alt text](./docs/db_schema.png)
576635

577636
The major tables in the schema are briefly described below -
578637

@@ -585,3 +644,5 @@ The major tables in the schema are briefly described below -
585644
**Leads** - this model represents a lead that could eventually be a tenant in the system
586645

587646
**Tenants** - main model of the service that represents a tenant in the system, either pooled or siloed
647+
648+
**TenantMgmtConfig** - to save any tenant specific data related to idP
760 KB
Loading
-130 KB
Binary file not shown.

services/tenant-management-service/src/models/tenant-config.model.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)