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
| Step | What the customer does | How your app does it |
|---|---|---|
| 1. Sign in | Authenticates | Customer sign-in: OpenID Connect, then the application, environment and tenant checks. |
| 2. Tenant selection | Picks a tenant when they belong to more than one | Read 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 navigation | Sees only what their role allows | Build the menu and the endpoints from the permission claim. Hide what is not allowed and enforce it again on the server. |
| 4. Team | Invites people, changes roles, removes members | TenancyEnginePortalTeamProxy.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 security | Manages MFA, passkeys, password, linked logins | TenancyEngineAccountSecurityProxy.ForwardAsync forwards the caller's own account-security routes with the caller's token. |
| 6. Plan and usage | Sees their plan, limits and consumption | GetRuntimeContextAsync(slug, environment, tenantId) returns features, limits and usage for the tenant. The embedded widget needs the unreleased token call above. |
| 7. Activity | Sees what changed in their data | Your 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_idis 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).