Base solution for your next web application
Open Closed

Access Token is showing abpwebsite domain for tenantId field #5011


User avatar
0
bolenton created

I wanted to know why the Access token I generated from my website domain shows 'tenantId' field along with abp website url. Is it possible to remove that url from token?


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

    Hi @bolenton,

    It is defined here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp/Runtime/Security/AbpClaimTypes.cs#L32">https://github.com/aspnetboilerplate/as ... pes.cs#L32</a>.

    You can change it in your application if you would like to.

  • User Avatar
    0
    bolenton created

    Thanks ismcagdas. But can you tell me how can I remove that url part from tenant Id as AbpClaimTypes is of metadata type and it has 4 references.So where can I do that and how - PrjName.Core\Authorization\Impersonation\ImpersonationManager.cs(55):
    identity.AddClaim(new Claim(AbpClaimTypes.ImpersonatorTenantId, cacheItem.ImpersonatorTenantId.Value.ToString(CultureInfo.InvariantCulture)));

    PrjName.Core\Authorization\Impersonation\ImpersonationManager.cs(58):
    identity.AddClaim(new Claim(AbpClaimTypes.ImpersonatorUserId, cacheItem.ImpersonatorUserId.ToString(CultureInfo.InvariantCulture)));

    PrjName..Core\Authorization\Users\UserLinkManager.cs(128):
    identity.AddClaim(new Claim(AbpClaimTypes.ImpersonatorTenantId, cacheItem.ImpersonatorTenantId.Value.ToString(CultureInfo.InvariantCulture)));

    PrjName.Core\Authorization\Users\UserLinkManager.cs(133):

    My AbpClaimTypes class is like this -

    public static class AbpClaimTypes
        {
            //
            // Summary:
            //     UserId. Default: System.Security.Claims.ClaimTypes.Name
            public static string UserName { get; set; }
            //
            // Summary:
            //     UserId. Default: System.Security.Claims.ClaimTypes.NameIdentifier
            public static string UserId { get; set; }
            //
            // Summary:
            //     UserId. Default: System.Security.Claims.ClaimTypes.Role
            public static string Role { get; set; }
            //
            // Summary:
            //     TenantId. Default: http://www.aspnetboilerplate.com/identity/claims/tenantId
            public static string TenantId { get; set; }
            //
            // Summary:
            //     ImpersonatorUserId. Default: http://www.aspnetboilerplate.com/identity/claims/impersonatorUserId
            public static string ImpersonatorUserId { get; set; }
            //
            // Summary:
            //     ImpersonatorTenantId Default: http://www.aspnetboilerplate.com/identity/claims/impersonatorTenantId
            public static string ImpersonatorTenantId { get; set; }
        }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    You can set it like below in the startup of your application

    AbpClaimTypes.TenantId = "xxxxx";
    

    But, don't set it to an empty string, otherwise it will cause some problems.

  • User Avatar
    0
    bolenton created

    <cite>ismcagdas: </cite> You can set it like below in the startup of your application

    AbpClaimTypes.TenantId = "xxxxx";
    

    But, don't set it to an empty string, otherwise it will cause some problems.

    Thank you ismcagdas. Your help is really appreciated.I was struggling with this issue from 4 days but your help solved that problem in 1 hour.Thanks a lot :D

  • User Avatar
    0
    alper created
    Support Team

    thanks for your feedback