Base solution for your next web application
Open Closed

Impersonation does not work when deployed to Azure as single solution #10676


User avatar
0
JapNolt created
  • What is your product version? 10.5
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? .net core
  • single solution

When impersonating a tenant, the site just redirects to the login page without any error. It works fine when debugging locally but not when deployed to Azure as a single solution.

It appears that when the FE redirects to https://sitename/?impersonationToken=<sometoken>&tenantId=<tenantid> that the backend just redirects the request to index.html and does not pass along the query parameters.

I've replicated this problem in a clean project download. You can test here: https://testanz105.azurewebsites.net/account/login


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @japnolt

    Thanks, I have requested the test credentials via email. We will take a look at this problem after your reply.

  • User Avatar
    0
    JapNolt created

    @ismcagdas Any update?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @japnolt

    I figured out the problem. This happens when you host both apps under the same website.

    In impersonation.service.ts, could you change impersonate function as below;

    impersonate(userId: number, tenantId?: number): void {
    
            const input = new ImpersonateInput();
            input.userId = userId;
            input.tenantId = tenantId;
    
            this._accountService.impersonate(input)
                .subscribe((result: ImpersonateOutput) => {
                    this._authService.logout(false);
    
                    let targetUrl = this._appUrlService.getAppRootUrlOfTenant(result.tenancyName) + 'index.html?impersonationToken=' + result.impersonationToken;
                    if (input.tenantId) {
                        targetUrl = targetUrl + '&tenantId=' + input.tenantId;
                    }
    
                    location.href = targetUrl;
                });
        }
    

    The change is, I have added index.html to the targetUrl parameter calculation.

  • User Avatar
    0
    JapNolt created

    Thanks @ismcagdas,

    I came up with a similar solution. I added a non-existant "page" to the path.

        this._accountService.impersonateTenant(input).subscribe((result: ImpersonateOutput) => {
            let targetUrl =
                this._appUrlService.getAppRootUrlOfTenant(result.tenancyName) +
                'it?impersonationToken=' +
                result.impersonationToken;
            if (input.tenantId) {
                targetUrl = targetUrl + '&tenantId=' + input.tenantId;
            }
    
            this._authService.logout(true, targetUrl);
        });
    

    note the "it" before ?impersonationToken

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Yes, this also works becasue not found URL's are redirected to index.html in merged solution.