Tenant impersonation & User impersonation
User impersonation allows you to temporarily sign in as a different user in your tenant's users. This article introduces how to enable impersonation in ABP. Impersonation is enabled by defautl in ABP v5.0 and above.
Introduction
In some cases, users need to sign in as another user and perform operations on behalf of the target user without sharing the target user's password.
How to enable impersonation feature?
If your ABP version is lower than 5.0, you can implement the impersonation feature by following the steps below.
Please remember to configure the
ImpersonationTenantPermission
andImpersonationUserPermission
permissions!!!
MVC
MVC Tiered
AuthServer
- Depends
AbpAccountPublicWebImpersonationModule(Volo.Abp.Account.Pro.Public.Web.Impersonation)
andSaasHostApplicationContractsModule
on yourAuthServerModule
- Configure the
AbpAccountOptions
.
HttpApi.Host
No need to do anything here.
Web
- Depends
AbpAccountPublicWebImpersonationModule(Volo.Abp.Account.Pro.Public.Web.Impersonation)
on yourWebModule
- Change the base class of
AccountController
toAbpAccountImpersonationChallengeAccountController
- Add
ImpersonationViewComponent
to\Components\Toolbar\Impersonation
folder
- Add
ImpersonationViewComponent
toToolbarContributor
.
- Configure
AbpSaasHostWebOptions
andAbpIdentityWebOptions
Blazor Server
- Depends
AbpAccountPublicWebImpersonationModule(Volo.Abp.Account.Pro.Public.Web.Impersonation)
andAbpAccountPublicBlazorServerModule(Volo.Abp.Account.Pro.Public.Blazor.Server)
on yourBlazorModule
- Configure
SaasHostBlazorOptions
andAbpAccountOptions
Blazor Server Tiered
AuthServer
- Depends
AbpAccountPublicWebImpersonationModule(Volo.Abp.Account.Pro.Public.Web.Impersonation)
andSaasHostApplicationContractsModule
on yourAuthServerModule
- Configure the
AbpAccountOptions
.
HttpApi.Host
No need to do anything here.
Blazor
Depends
AbpAccountPublicWebImpersonationModule(Volo.Abp.Account.Pro.Public.Web.Impersonation)
andAbpAccountPublicBlazorServerModule(Volo.Abp.Account.Pro.Public.Blazor.Server)
on yourBlazorModule
Change the base class of
AccountController
toAbpAccountImpersonationChallengeAccountController
- Configure
SaasHostBlazorOptions
andAbpAccountOptions
Angular
Add Impersonation
to the Angular grant types.
Add impersonation: { userImpersonation: true, tenantImpersonation: true}
object to oAuthConfig
of environment
if not exits.
Blazor WASM
It is currently not supported.
Microservice
AuthServer
- Depends
AbpAccountPublicWebImpersonationModule(Volo.Abp.Account.Pro.Public.Web.Impersonation)
andSaasHostApplicationContractsModule
on yourAuthServerModule
- Configure the
AbpAccountOptions
.
Web
- Depends
AbpAccountPublicWebImpersonationModule(Volo.Abp.Account.Pro.Public.Web.Impersonation)
on yourWebModule
- Change the base class of
AccountController
toAbpAccountImpersonationChallengeAccountController
- Add
ImpersonationViewComponent
to\Components\Toolbar\Impersonation
folder
- Add
ImpersonationViewComponent
toToolbarContributor
.
- Configure
AbpSaasHostWebOptions
andAbpIdentityWebOptions
Blazor.Server
Depends
AbpAccountPublicWebImpersonationModule(Volo.Abp.Account.Pro.Public.Web.Impersonation)
andAbpAccountPublicBlazorServerModule(Volo.Abp.Account.Pro.Public.Blazor.Server)
on yourBlazorModule
Change the base class of
AccountController
toAbpAccountImpersonationChallengeAccountController
- Configure
SaasHostBlazorOptions
andAbpAccountOptions
Blazor and PublicWeb
It is currently not supported.
Tenant & User Impersonation permissions