Skip to content

Tenant customer console pattern ​

A sign-in page that only proves who someone is does not make a customer console. This page describes the screens and checks a tenant-facing console for your product needs, and which TenancyEngine pieces supply each one. It is a pattern to build in your app, not a package.

Requires TenancyEngine.Sdk 2.3.0. The plan and usage widget token (CreateUsageWidgetTokenAsync) is in the source (2.5.0) but not yet released; the rest uses released types.

The shape ​

StepWhat the customer doesHow your app does it
1. Sign inAuthenticatesCustomer sign-in: OpenID Connect, then the application, environment and tenant checks.
2. Tenant selectionPicks a tenant when they belong to more than oneRead the tenant from the verified tenant_id claim. If a person works in several tenants, offer a switcher that starts a new sign-in for the other tenant. Never accept a tenant id from a URL or form without comparing it to the claim.
3. Permission-gated navigationSees only what their role allowsBuild the menu and the endpoints from the permission claim. Hide what is not allowed and enforce it again on the server.
4. TeamInvites people, changes roles, removes membersTenancyEnginePortalTeamProxy.ForwardAsync forwards six team routes (list members, list invitations, invite, change role, remove member, cancel invitation) with the signed-in person's own access token. The platform decides who may do what (tenant admins, own tenant only).
5. Account securityManages MFA, passkeys, password, linked loginsTenancyEngineAccountSecurityProxy.ForwardAsync forwards the caller's own account-security routes with the caller's token.
6. Plan and usageSees their plan, limits and consumptionGetRuntimeContextAsync(slug, environment, tenantId) returns features, limits and usage for the tenant. The embedded widget needs the unreleased token call above.
7. ActivitySees what changed in their dataYour own audit view, from your audit table. The organization audit log is for organization admins in the TenancyEngine console.

Server rules ​

  • Every query carries the tenant key from the verified token. A missing tenant_id is a rejected request.
  • Authorize on permission, not on a role name, so a role can be redefined without a code change.
  • Forward the person's token to the proxies only on routes you expose for that person. The proxies are allowlisted forwarders: they refuse any other path.
  • Keep the session short and re-check claims on refresh (see Sessions and revocation).

Hosting the team and security screens ​

The proxies are the server half. Build the screens on the routes the proxies forward (/api/v1/portal/team... and /api/v1/account/security/...). Both proxies return the platform's status code, content type and body unchanged, so your API passes them straight to the browser.

Not provided ​

  • A reference sample app for this pattern.
  • A packaged sign-in and permission policy for ASP.NET Core (tenancyengine#1576).

TenancyEngine platform documentation