Hi, I have created the ticket
https://abp.io/support/questions/7989/User-profile-picture-section-not-visible-after-user-logs-in
Reference ticket : https://abp.io/support/questions/7882/Override-the-existing-Users-Roles--Permissions-Methodology
Consider the above ticket for reference.
After the user successfully logs into the angular application, on the top right corner area, we should have a section where there is a profile picture of the user displayed and under which the username of the user is displayed. And when clicked on profile picture, a small box section is displayed to execute user related actions.
Example :
But instead of this, we are getting the right arrow icon, clicking on which it will be redirected to the Auth Server. Just like how when it's there when the user is logged out.
Also, here is the value of currentUser property of the response of the abp app configuration api call when breakpoint hits on the auth server project
"currentUser": { "isAuthenticated": true, "id": "3a0daa97-5fba-2079-563c-3e26309bdc81", "tenantId": "3a0daa97-5b6d-e661-4f00-22309be7478d", "impersonatorUserId": null, "impersonatorTenantId": null, "impersonatorUserName": null, "impersonatorTenantName": null, "userName": "admin", "name": null, "surName": null, "email": "safwan@gmail.com", "emailVerified": false, "phoneNumber": null, "phoneNumberVerified": false, "roles": [ "admin" ], "sessionId": null },
"sub: 3a0daa97-5fba-2079-563c-3e26309bdc81" "preferred_username: admin" "email: safwan@gmail.com" "AspNet.Identity.SecurityStamp: 6DCVHJYKEIHLAYOAR3SQBAPWS23CADJ5" "role: admin" "tenantid: 3a0daa97-5b6d-e661-4f00-22309be7478d" "amr: pwd"
Endpoint : https://test2dev.localhost:44322/connect/token
Payload : grant_type: authorization_code code: nbTa2qb06FU_FlB3rvA8zFORItoJNIZhFC6yDM_fJyg redirect_uri: http://test2dev.localhost:4200 code_verifier: NHVvdURWZ2tRUnd4NGEyTFFEVkd2Q2RxOGdmQVVuZkdMVjdRVURVZmtmUEZy client_id: Angular
Response : { "access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjEzQkQ5MUI5RTFDRkI2QjJGRTQ2OEQ1REE1NTUwMjc0NjcyNDFCRjMiLCJ4NXQiOiJFNzJSdWVIUHRyTC1SbzFkcFZVQ2RHY2tHX00iLCJ0eXAiOiJhdCtqd3QifQ.eyJpc3MiOiJodHRwczovL3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VyhZD0MrjfJqvKWXEerDFBTM15LeKbupWj0jDdJfYmQS0Im1CJFWokVSwG5bywliuvlQjEpswuOO-lmDlGbtVHJZYvq9AWh0OrgmQYIsyC1MYBbKpF4yclgTxu2k4CCec-dybdQD6YfK-ON-mAGhUqSGZ4Vy3nqhQ1CSObRGVPtW0u9tK82wasvnpKBvKsvILXTPlKlVNvBNDGuJAVcNWkZafZW6mwLeO7ayfkTu4t2n6rDTYrHtoYV-KutEFhC5URYdfHH-YEBkwAlbwxCkgB3Q", "token_type": "Bearer", "expires_in": 3598, "scope": "offline_access openid profile email phone AccountService IdentityService AdministrationService SaasService ProductService ClinicService AppointmentService FormsService", "id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjEzQkQ5MUI5RTFDRkI2QjJGRTQ2OEQ1REE1NTUwMjc0NjcyNDFCRjMiLCJ4NXQiOiJFNzJSdWVIUHRyTC1SbzFkcFZVQ2RHY2tHX00iLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL3Rlc3QyZGV2LmxvY2FsaG9zdDo0NDMyMi8iLCJleHAiOjE3Mjc0MTUxMzUsImlhdCI6MTcyNzQxMzkzNSwiYXVkIjoiQW5ndWxhciIsInN1YiI6IjNhMGRhYTk3LTVmYmEtMjA3OS01NjNjLTNlMjYzMDliZGM4MSIsInByZWZlcnJlZF91c2VybmFtZSI6ImFkbWluIiwiZW1haWwiOiJzYWZ3YW5AZ21haWwuY29tIiwidGVuYW50aWQiOiIzYTBkYWE5Ny01YjZkLWU2NjEtNGYwMC0yMjMwOWJlNzQ3OGQiLCJvaV9hdV9pZCI6IjNhMTRlY2FmLWRhZTAtZDUzNS00MjAxLTcxOTdlNmUzMDkyZSIsImF6cCI6IkFuZ3VsYXIiLCJub25jZSI6ImMyRkhPVzVqYW01c1lUWi1haTE1YkZOUmQwUkxhMmRQWkVvNFVsOHdWVEJXZmtNdU1sRkxVMDgwVVZZNCIsImF0X2hhc2giOiJnb29ET01vcFQxVTBIVG81Z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Hi, I am finally able to get into the angular application with the user, but because the claims of the user doesn't have the Tenant Id as a claim, it fetches all the permissions and assigns to the user, we want only those permissions which are related to Tenant (i.e., Permissions from the AbpPermissions table with MultiTenancySide as 1 or 3).
For that, because the claim doesn't contain the TenantId, I had to manually add the claim like this :
protected override async Task<ClaimsIdentity> GenerateClaimsAsync(Volo.Abp.Identity.IdentityUser user)
{
var id = await base.GenerateClaimsAsync(user).ConfigureAwait(false);
var existingRoleClaims = id.Claims.Where(x => x.Type == ClaimTypes.Role).ToList();
foreach (var item in existingRoleClaims)
{
id.RemoveClaim(item);
}
if (UserManager.SupportsUserRole)
{
var roles = await IdentityUserManager.GetRoleNamesAsync(user).ConfigureAwait(false);
foreach (var roleName in roles)
{
id.AddClaim(new Claim(Options.ClaimsIdentity.RoleClaimType, roleName));
if (RoleManager.SupportsRoleClaims)
{
var role = await IdentityRoleManager.FindByNameAsync(roleName).ConfigureAwait(false);
if (role != null)
{
id.AddClaims(await RoleManager.GetClaimsAsync(role).ConfigureAwait(false));
}
}
}
}
********** THIS LINE I ADDED ***********
id.AddClaim(new Claim(AbpClaimTypes.TenantId, user.TenantId.ToString()));
return id;
}
I added that line in the code to achieve this.
Now, after all this, I am able to get the permissions related only to Tenants, but I am getting this login icon even after user being logged in.
And I also observed that when I check in the abp configuration response :
"currentUser": {
"isAuthenticated": true,
"id": "3a0daa97-5fba-2079-563c-3e26309bdc81",
"tenantId": "3a0daa97-5b6d-e661-4f00-22309be7478d",
"impersonatorUserId": null,
"impersonatorTenantId": null,
"impersonatorUserName": null,
"impersonatorTenantName": null,
"userName": null,
"name": null,
"surName": null,
"email": "safwan@gmail.com",
"emailVerified": false,
"phoneNumber": null,
"phoneNumberVerified": false,
"roles": [
"admin"
],
"sessionId": null
},
Here some of the claims are missing, like sessionId, username, name, I think it might be related to that, can you guide?
While in the other tab where angular app is continuously reloading, I check in the network tab,
https://test2dev.localhost:44322/connect/token
this api is failing with 400 error code bad request.
{error: "invalid_grant", error_description: "The token is no longer valid.",…}
I folowed the steps, and after logging in, the angular app kept reloading the same logged out page, while in another tab I opened the Auth Server project URL, put a breakpoint at the OnGetAsync method in the Login.cshmtl.cs page.
And there we have the ICurrentPrincipalAccessor injected in the class, there I checked the claims in the principal, but the list was empty. There are no claims in the principal there. And I also check the values of CurrentUser, and it was also having null and default values, that means the current user is not having the correct values.
It's trying to check the TenantId claim from this method from the AbpClaimsIdentityExtensions file (namespace System.Security.Principal)
public static Guid? FindTenantId(this ClaimsPrincipal principal)
{
Check.NotNull(principal, "principal");
Claim claim = principal.Claims?.FirstOrDefault((Claim c) => c.Type == AbpClaimTypes.TenantId);
if (claim == null || claim.Value.IsNullOrWhiteSpace())
{
return null;
}
if (Guid.TryParse(claim.Value, out var result))
{
return result;
}
return null;
}
I tried to debug here and here the
principal.Claims?.FirstOrDefault((Claim c) => c.Type == AbpClaimTypes.TenantId);
this line is returning null as a claim, i.e., TenantId is not present as a claim in the principal and about the roles part, this is the list of claims I am getting in the principal variable and I am not seeing roles as a claim in the list, so I think roles claim is also not present in the principal.
"iss: https://test2dev.localhost:44322/" "exp: 1727326332" "iat: 1727326032" "oi_cl_dstn: {""oi_scp"":[""access_token""],""oi_au_id"":[""access_token""],""preferred_username"":[""access_token"",""id_token""],""email"":[""access_token"",""id_token""],""sub"":[""access_token""],""oi_rsrc"":[""access_token""]}" "sub: 3a0daa97-5fba-2079-563c-3e26309bdc81" "preferred_username: admin" "email: safwan@gmail.com" "AspNet.Identity.SecurityStamp: 6DCVHJYKEIHLAYOAR3SQBAPWS23CADJ5" "oi_scp: offline_access" "oi_scp: openid" "oi_scp: profile" "oi_scp: email" "oi_scp: phone" "oi_scp: AccountService" "oi_scp: IdentityService" "oi_scp: AdministrationService" "oi_scp: SaasService" "oi_scp: ProductService" "oi_scp: ClinicService" "oi_scp: AppointmentService" "oi_scp: FormsService" "oi_rsrc: AccountService" "oi_rsrc: IdentityService" "oi_rsrc: AdministrationService" "oi_rsrc: SaasService" "oi_rsrc: ProductService" "oi_rsrc: ClinicService" "oi_rsrc: AppointmentService" "oi_rsrc: FormsService" "oi_prst: Angular" "oi_reduri: http://test2dev.localhost:4200" "oi_cd_chlg: jHXfUpUcsI-oJ5MA5vuDsguSstUszWkzRNGZzxhZTbM" "oi_cd_chlg_meth: S256" "oi_nce: QVF6bU1EczNQd1p2VlpBRmt5cFl5SkFmeWVFSkJGUmhmN2M0dWNaZTNMTFZq" "oi_crt_dt: Thu, 26 Sep 2024 04:47:12 GMT" "oi_exp_dt: Thu, 26 Sep 2024 04:52:12 GMT" "oi_au_id: 3a14ecaf-dae0-d535-4201-7197e6e3092e" "oi_tkn_id: 3a153ed4-6d5e-82a6-ce8e-639fe91a5623" "oi_tkn_typ: authorization_code"
I have also pushed the MyAuthorizeController file that I have added to the repository, if they can check that.
I am able to register the controller now, but now again the same loop is going on, it just keeps redirecting to the angular app's logged out page and I have put breakpoints at
protected async override Task<IActionResult> HandleAuthorizationCodeAsync(OpenIddictRequest request)
and
public override async Task<IActionResult> HandleAsync()
It just keeps hitting at these 2 places continuously, I will share you the logs.