Admin impersonate should be possible within organization roles #1367

Open
opened 2026-03-13 08:35:11 -05:00 by GiteaMirror · 10 comments
Owner

Originally created by @madsh93 on GitHub (Jun 17, 2025).

Is this suited for github?

  • Yes, this is suited for github

No response

Describe the solution you'd like

Currently we can call:

  await authClient.admin.impersonateUser({
    userId: id
  })

But it is only usable for users with the role admin.

But when using the organization plugin, i'd like admins and owners within an organization to be able to impersonate other members within the organization that has a lower status in the hierarchy.

Describe alternatives you've considered

I could have to try and build it custom.

Additional context

No response

Originally created by @madsh93 on GitHub (Jun 17, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. _No response_ ### Describe the solution you'd like Currently we can call: ```js await authClient.admin.impersonateUser({ userId: id }) ``` But it is only usable for users with the role `admin`. But when using the `organization` plugin, i'd like admins and owners within an organization to be able to impersonate other members within the organization that has a lower status in the hierarchy. ### Describe alternatives you've considered I could have to try and build it custom. ### Additional context _No response_
GiteaMirror added the enhancement label 2026-03-13 08:35:11 -05:00
Author
Owner

@dimitrisnl commented on GitHub (Jun 17, 2025):

This seems like an app feature, rather than part of the system admin functionality

@dimitrisnl commented on GitHub (Jun 17, 2025): This seems like an app feature, rather than part of the system admin functionality
Author
Owner

@gwoodbridge commented on GitHub (Jun 17, 2025):

The admin role from the organization plugin is not equivalent to the admin role from the admin plugin. The organization plugin adds roles to the member table in your database to allow for users to have multiple roles within separate organizations. The admin plugin adds the user or admin role to the users table. It can be confusing since both roles are "admin" but checking the roles require different api calls for either plugin.

You can have this app functionality by checking what role you are assigning in the organization and if it is owner or admin, add the admin role from the admin plugin.

@gwoodbridge commented on GitHub (Jun 17, 2025): The admin role from the organization plugin is not equivalent to the admin role from the admin plugin. The organization plugin adds roles to the member table in your database to allow for users to have multiple roles within separate organizations. The admin plugin adds the user or admin role to the users table. It can be confusing since both roles are "admin" but checking the roles require different api calls for either plugin. You can have this app functionality by checking what role you are assigning in the organization and if it is owner or admin, add the admin role from the admin plugin.
Author
Owner

@madsh93 commented on GitHub (Jun 18, 2025):

The admin role from the organization plugin is not equivalent to the admin role from the admin plugin. The organization plugin adds roles to the member table in your database to allow for users to have multiple roles within separate organizations. The admin plugin adds the user or admin role to the users table. It can be confusing since both roles are "admin" but checking the roles require different api calls for either plugin.

You can have this app functionality by checking what role you are assigning in the organization and if it is owner or admin, add the admin role from the admin plugin.

Yes I am aware, but there are security concerns. This would effectively mean that they can impersonate users from different organizations.

@madsh93 commented on GitHub (Jun 18, 2025): > The admin role from the organization plugin is not equivalent to the admin role from the admin plugin. The organization plugin adds roles to the member table in your database to allow for users to have multiple roles within separate organizations. The admin plugin adds the user or admin role to the users table. It can be confusing since both roles are "admin" but checking the roles require different api calls for either plugin. > > You can have this app functionality by checking what role you are assigning in the organization and if it is owner or admin, add the admin role from the admin plugin. Yes I am aware, but there are security concerns. This would effectively mean that they can impersonate users from different organizations.
Author
Owner

@madsh93 commented on GitHub (Jun 18, 2025):

To put more context to this.

I have a multi tenant app (organizations). Each organization has a bunch of members (admins, members and custom roles). Now we have a role called "customers" which gets their own dashboard, where they can see their orders etc. sort of like any other e-commerce/saas. I'd like admins or owners of an organization to be able to impersonate their customers.

But I assume it may be too niche to get built.

@madsh93 commented on GitHub (Jun 18, 2025): To put more context to this. I have a multi tenant app (organizations). Each organization has a bunch of members (admins, members and custom roles). Now we have a role called "customers" which gets their own dashboard, where they can see their orders etc. sort of like any other e-commerce/saas. I'd like admins or owners of an organization to be able to impersonate their customers. But I assume it may be too niche to get built.
Author
Owner

@stefano-8wave commented on GitHub (Jul 1, 2025):

Yes, it would be wonderful if we can set the "impersonate" permission, but also these permissions:
user: create list set-role ban impersonate delete set-password
session: list revoke delete

on the organization roles. The impersonate should works only on users of the same organization obviously.

@stefano-8wave commented on GitHub (Jul 1, 2025): Yes, it would be wonderful if we can set the "impersonate" permission, but also these permissions: user: create list set-role ban impersonate delete set-password session: list revoke delete on the **organization roles**. The impersonate should works only on users of the same organization obviously.
Author
Owner

@dosubot[bot] commented on GitHub (Sep 30, 2025):

Hi, @madsh93. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You requested extending the admin impersonation feature to allow organization admins and owners to impersonate members with lower roles within their organization, not just global admins.
  • Maintainers noted this might be more appropriate as an app-level feature rather than a core library feature.
  • Discussion highlighted the distinction between global and organization admin roles and current impersonation requiring global admin privileges.
  • You raised security concerns about cross-organization impersonation and shared a multi-tenant app use case.
  • Other users expressed support for adding granular impersonation permissions scoped to organization roles.

Next Steps:

  • Please let me know if this issue is still relevant to the latest version of better-auth by commenting here to keep the discussion open.
  • If I do not hear back within 7 days, this issue will be automatically closed.

Thanks for your understanding and contribution!

@dosubot[bot] commented on GitHub (Sep 30, 2025): Hi, @madsh93. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You requested extending the admin impersonation feature to allow organization admins and owners to impersonate members with lower roles within their organization, not just global admins. - Maintainers noted this might be more appropriate as an app-level feature rather than a core library feature. - Discussion highlighted the distinction between global and organization admin roles and current impersonation requiring global admin privileges. - You raised security concerns about cross-organization impersonation and shared a multi-tenant app use case. - Other users expressed support for adding granular impersonation permissions scoped to organization roles. **Next Steps:** - Please let me know if this issue is still relevant to the latest version of better-auth by commenting here to keep the discussion open. - If I do not hear back within 7 days, this issue will be automatically closed. Thanks for your understanding and contribution!
Author
Owner

@stefano-8wave commented on GitHub (Oct 1, 2025):

this issue is still relevant

@stefano-8wave commented on GitHub (Oct 1, 2025): this issue is still relevant
Author
Owner

@SimonTernoir commented on GitHub (Nov 11, 2025):

Hi, thanks for keeping this discussion open.

Has there been any progress or workaround identified for this request @madsh93?
It would be indeed very useful to support impersonation at the organization level without requiring global admin privileges.

I’ve seen the earlier comments suggesting that this could be implemented at the application level, but it’s not obvious how to do that in practice since even when using the server-side SDK, the impersonation endpoint still requires the user to have the admin role, which effectively grants the ability to impersonate anyone (which is a serious security concern).

If there’s any guidance or example on how this could be safely implemented application-side, I’d really appreciate it.

@SimonTernoir commented on GitHub (Nov 11, 2025): Hi, thanks for keeping this discussion open. Has there been any progress or workaround identified for this request @madsh93? It would be indeed very useful to support impersonation at the organization level without requiring global admin privileges. I’ve seen the earlier comments suggesting that this could be implemented at the application level, but it’s not obvious how to do that in practice since even when using the server-side SDK, the impersonation endpoint still requires the user to have the admin role, which effectively grants the ability to impersonate anyone (which is a serious security concern). If there’s any guidance or example on how this could be safely implemented application-side, I’d really appreciate it.
Author
Owner

@pranavgoel29 commented on GitHub (Jan 28, 2026):

Is there’s any update on this, it would be great, especially for those using the org plugin. 😊

@pranavgoel29 commented on GitHub (Jan 28, 2026): Is there’s any update on this, it would be great, especially for those using the org plugin. 😊
Author
Owner

@AdamJSoftware commented on GitHub (Mar 2, 2026):

Same, wondering if there is any update on this. Or an ability/example to manually set the cookie on the application side.

@AdamJSoftware commented on GitHub (Mar 2, 2026): Same, wondering if there is any update on this. Or an ability/example to manually set the cookie on the application side.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1367