Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Role, permission Problem #7844


User avatar
0
hung.le@cyberlotus created

Hi,

I have a issue about roles, permissions. I'm using redis cache for my applications. On the first application (web server 1), i set permissions for the role. But on the 2nd application (web server 2), users do not fetch the new permissions always. After some time, the user gets the permissions. I want the users will get the pissmission always. Is there any way to update these permissions?

Can you help me to resolve this issue?

Thanks.


14 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team
    • What is your product version?
    • What is your product type (Angular or MVC)?
    • What is product framework type (.net framework or .net core)?
  • User Avatar
    0
    hung.le@cyberlotus created
    • My product version is v6.8.0
    • My product type is ASP.NET CORE & Angular

    Thanks.

  • User Avatar
    0
    hung.le@cyberlotus created

    I'm using ICacheManager to remove key("n:AbpZeroRolePermissions,c:1@0") on redis server but it is not working, it's still on redis server.

    _cacheManager.GetCache(KEY).Remove(VALUE);

  • User Avatar
    0
    maliming created
    Support Team

    On the first application (web server 1), i set permissions for the role. But on the 2nd application (web server 2), users do not fetch the new permissions always.

    Is web server 2 an angular application?

    If it is angular, can the refresh (F5) angular page get the latest permission information?

  • User Avatar
    0
    hung.le@cyberlotus created

    Is web server 2 an angular application? No, on server 1 (include backend .net core + angular application) for admin, on server 2: (.net core + angular application) for customer users.

    After the user logout and login on the product application again but still not get the latest permission information.

  • User Avatar
    0
    maliming created
    Support Team

    In other words, your web server1 and web server 2 use the same database and the same redis cache.

    The default abp will automatically invalidate the cache when the permissions of the role or user change. https://github.com/aspnetboilerplate/aspnetboilerplate/blob/773d6355dd61a412ba9cdf8bae0a63c637138bbb/src/Abp.Zero.Common/Authorization/Roles/AbpRolePermissionCacheItemInvalidator.cs#L17

    Can you try to disable all the permissions of a role and see if the content of redis has changed?

  • User Avatar
    0
    hung.le@cyberlotus created

    i tried add or remove the permissions of a role, but the content is still not change on redis cache (redis-cli).

  • User Avatar
    0
    maliming created
    Support Team

    I use the latest Zero to grant/reject permissions to Role, and redis changes as expected.

    If your application redis doesn't work, can you share your project code with me? I can debug it locally.

    my email: [email protected]

  • User Avatar
    0
    hung.le@cyberlotus created

    Sorry, I can not share my project source code with you. I using method await UpdateGrantedPermissionsAsync(role, input.GrantedPermissionNames, input.TenantId); to change the permissions of a role.

    And after i change the permissions, on redis cache it is not remove and the content is not change:

  • User Avatar
    0
    hung.le@cyberlotus created

    I tried remove directly the key cache as using iCacheManager.GetRolePermissionCache().Remove("n:AbpZeroRolePermissions,c:68@6"); but it's not working.

  • User Avatar
    0
    maliming created
    Support Team

    iCacheManager.GetRolePermissionCache().Remove("n:AbpZeroRolePermissions,c:68@6"); but it's not working.

    Try

    var cacheKey = RoleId + "@" + (TenantId ?? 0); 
     _cacheManager.GetRolePermissionCache().Remove(cacheKey);
    

    I am confused about your code, why do you need to manually set the tenant's Id. Maybe you can download a Zero Demo project to see if it has the same problem.

  • User Avatar
    0
    hung.le@cyberlotus created

    Try

    var cacheKey = RoleId + "@" + (TenantId ?? 0); _cacheManager.GetRolePermissionCache().Remove(cacheKey);

    I tried iCacheManager.GetRolePermissionCache().Remove("68@6"); but the key "n:AbpZeroRolePermissions,c:68@6" is still on redis cache server. I think I have problem with ICacheManager.

    I using the tenant's Id on here:

    Thanks.

  • User Avatar
    0
    maliming created
    Support Team

    Can I use teamviewer to remotely view your application. If you can, please send teamviewer connection information to [email protected]

  • User Avatar
    0
    ismcagdas created
    Support Team

    This issue is closed because it has not had recent activity for a long time.