Open Closed

Tenant Impersonation By User #10525


User avatar
0
cvarela@ld created

Check the docs before asking a question: https://abp.io/docs/latest Check the samples to see the basic tasks: https://abp.io/docs/latest/samples The exact solution to your question may have been answered before, and please first use the search on the homepage.

Provide us with the following info: 🧐 Hint: If you are using the ABP Studio, you can see all the information about your solution from the configuration window, which opens when you right-click on the solution and click on the Solution Configuration button.

Hello!

We're looking to customize how tenant impersonation works in our ABP tiered solution. From the SaaS > Tenants option we have the ability to impersonate a tenant using the option: "Login with this tenant", however the default user that's displayed for the impersonation is the "admin" user from the tenant :Is it possible to modify this behavior? we would like the default user for impersonation to change depending on the user that logged into the host. For example, if the user that logged into the host is not an admin we don't want to allow them to impersonate the admin of the tenant.


4 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • In ABP, tenant impersonation (ā€œLogin with this tenantā€) is implemented as part of the Account impersonation system. The UI is intentionally designed to ask a user name to impersonate inside the target tenant, and it prefills that textbox with admin (the conventional tenant admin username created by the templates/seed).
    • There is no supported configuration point (setting/option) in ABP that changes this default/prefilled username based on the currently logged-in host user.
    • The supported way to enforce your rule (ā€œnon-admin host users must not impersonate tenant adminā€) is to prevent/limit the action, not to rely on changing the prefilled username:
      1. Restrict the permission for tenant impersonation to a specific host role (e.g., only Host Admins). In practice, remove/grant the tenant impersonation permission only to allowed host-side roles/users so non-admin host users can’t use ā€œLogin with this tenantā€ at all.
      2. If you need finer control than simple permission/role checks, implement your own ā€œLogin with this tenantā€ flow (custom UI + custom application service) and validate the requested target username/user on the server side before generating the impersonation URL (i.e., deny impersonating admin unless the current host user meets your criteria).

    Sources:

    • https://abp.io/docs/latest/modules/account/impersonation

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    cvarela@ld created

    We want to have finer control so implementing our own ā€œLogin with this tenantā€ flow would be the way to go. Can you point me to some documentation on how to do this?

  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • The official entry point is the Account module’s impersonation feature. The documentation explains the concept (tenant impersonation + user impersonation) and the built-in endpoints/flow you can replicate from your own UI:

      • Use the built-in impersonation endpoints (from your own button/action) and then redirect the browser to the returned URL to complete the impersonation.
    • In practice, your ā€œcustom Login with this tenantā€ flow is:

      1. Create your own UI action/button on the tenant list row.
      2. Call the Account impersonation API (tenant/user impersonation, depending on what you want).
      3. Apply your custom server-side rules before calling/allowing impersonation (e.g., deny if target user is admin and current host user is not allowed).
      4. Redirect to the URL returned by the impersonation endpoint.

    Links:

    • https://abp.io/docs/latest/modules/account/impersonation

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    cvarela@ld created

    The overall flow of what needs to be done is clear to me but how do I call the Account impersonation API? is there a service or controller I need to override? also how do I replace the original "Login with this tenant option" from the tenant dropdown?

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ā¤ļø on ABP v10.3.0-preview. Updated on March 13, 2026, 12:51
1
ABP Assistant
šŸ” You need to be logged in to use the chatbot. Please log in first.