I have a question about best practices for multi-t...
# ask-a-descoper
a
I have a question about best practices for multi-tenancy permissions for project level admins. We have a multi-tenant system where each of our client users is assigned a specific tenant, and they can't move between tenants. But we want that we, the users managing the project, could login to every tenant. And I'm wondering what are the best practices here surrounding that. Should I create a new user role for the project admin? Should I assign our company users to all of our project's tenants so they could switch the active one between them? Should I add / remove tenants for an admin user using the management APIs when a user switches between tenants? Or am I going the wrong about it completely and it should be a user impersonation flow?
r
Hi Avihu, User impersonation is the recommended approach for your use case. User impersonation enables privileged users to act on behalf of another user, which is particularly useful for troubleshooting and user support. This is exactly what you need - allowing project-level admins to access any tenant without permanently assigning them to all tenants. How impersonation works: Only users with the
Impersonate
permission can impersonate other users. This permission can be assigned at two levels: • Project-level: Allows impersonating any user in the project • Tenant-level: Restricts impersonation to users within a specific tenant For your scenario, you'd assign the project-level
Impersonate
permission to your admin users. Check this doc: https://docs.descope.com/user-impersonation
✅ 1
a
Thanks. Looking into this.
Just to reiterate the impersonation flow as I understand it from your docs in a nutshell, I create service users in each tenant that each of our project admins can impersonate. Then I create a flow that allows users with a project level impersonation flow to impersonate those specific users?
r
Let me check
No, that's not quite right. You don't need to create separate service users in each tenant for impersonation The actual flow is simpler: 1. Your project admins authenticate as themselves (they're real users in your project) 2. They have the
Impersonate
permission assigned at the project level 3. When they need to access a specific tenant, they impersonate an existing client user who belongs to that tenant The impersonation flow requires an input field for the
Impersonated User
login ID. Your admin would enter the login ID of any actual client user in the target tenant. Example flow: • Admin logs in as themselves • Admin enters a client user's login ID (e.g.,
<mailto:client@tenant-a.com|client@tenant-a.com>
) • The
User / Impersonate
action validates the admin has the
Impersonate
permission • Admin now has a session as that client user, with full access to that tenant's context The session JWT will show the impersonated user's ID in the
sub
claim and the impersonator's ID in the
act.sub
claim. You're not creating dummy/service users - you're impersonating real client users to see exactly what they see and troubleshoot in their context.