Login to follow
Tenant Hub

Tenant Hub (ODC)

Stable version 1.0.3 (Compatible with ODC)
Uploaded on 09 October 2024 by Vopak
Tenant Hub

Tenant Hub (ODC)

Documentation
1.0.3

Runbook also available here.


Video with a step by step on how to make your app multi-tenant here.


Requirements

  • The following applications must be installed from the Forge
    • Tenant Hub (Provides all the UI to manage Tenants, Users, Roles, Groups and Settings)
    • Tenant Hub Library (Expose Service Actions and Client Actions to provide multi-tenant capabilities to your applications)
    • Multi-Tenant Template App (An example application where we can copy already built multi-tenant functionality to help during the transition to multi-tenant or to be used as a base to a new multi-tenant application by cloning this app)


How to setup Tenant Hub

  • Navigate to Tenant Hub app in ODC Portal
    • Configure Setting "API_v1_Token" with a Token generated by you (ex. use https://passwordsgenerator.net/ to generate a strong one)

      Store it safely, you'll need it when making your application multi-tenant


How to make your application Multi-Tenant


  • Open both apps in ODC Studio
    1. Open app "Multi-Tenant Template App" (let's call it Template app)
    2. Open your app to become Multi-Tenant (let's call it Your app)
  • In Your app
    1. Create Setting: TenantHub_ApplicationId
    2. Create one Setting for each App Role for example: TenantHub_RoleId_Admin, TenantHub_RoleId_Viewer
    3. Create one Setting for each existing Setting that should also be MultiTenant: TenantHub_SettingId_MaxRecords
    4. Copy from the Template to Your app: ServerActions Folder "TenantHub"
    5. Copy from the Template to Your app: ClientActions Folder "TenantHub"
    6. Copy from the Template to Your app: ClientAction OnApplicationReady
    7. Copy from the Template to Your app: Client Variable TenantName
    8. Delete Common\OnException
    9. Delete Common\Login
    10. Copy Common\OnException, Common\Login, Common\TenantBroker, Common\Select, Common\TenantInfo
    11. Add Block TenantInfo inside block UserInfo in the logged in condition True
    12. Fix Server Action TenantHub/SwitchTenant by replacing the Role Granting actions by the correct Application Role ones based on the Switch Node Condition
    13. Fix Server Action TenantHub/RevokeRoles by replacing the Revoke Roles by the Revoke Roles from all existing Application Roles
    14. Change all Entities intended to be Mluti-Tenant: Add mandatory attribute TenantId (Text, 36) (Recommended to be positioned right after the PrimaryKey)
    15. Change Multi-Tenant Entities CRUD actions Create, CreateOrUpdate, Update, to assign the TenantId with function "GetTenantId()" from TenantHubLibrary
    16. Change all Screen Aggregates querying Multi-Tenant entities to add a Filter "{Entity}.[TenantId] = GetTenantId()"
    17. Change all Adv. Queries querying Multi-Tenant entities to add a where clause "{Entity}.[TenantId] = @TenantId" and use the function GetTenantId() for the @TenantId input
    18. Change all Timers intended to be Multi-Tenant to first retrieve a list of Tenants, do a SwitchTenant and run the timer logic within each iteration
    19. Hide Warnings related to the Tenant Hub related to OnInitialize and Exposing Service Actions to public access, they are meant to be
    20. Publish your application
  • Navigate to Tenant Hub app as a Global Admin
    1. Create Application, Roles and Settings (new entries Ids will be needed after to set up the App Settings)
  • Navigate to Your App in ODC Portal
    1. Configure Settings, configure all TenantHub_ settings with the corresponding Ids created in the previous step
    2. Configure Setting API_TenantHub_v1_Token with the same token used in the Tenant Hub > API_v1_Token Setting
    3. Configure Consumed Rest v1 endpoint and replace "replace-host" with the host used to accessed your apps
  • Navigate to Tenant Hub app as a Global Admin
    1. Create the Tenants your application will use
    2. In the created Tenants, select which Apps can access those Tenants
    3. Manage the users within each Tenant and their Roles