Open Closed

Dynamic claims not working in microservice solution #9226


User avatar
0
aziz.bouhejba created

Hello, we noticed that when demote/change the role of someone, it doesn't get reflected instantly. we figured it's because caching. but we thought UseDynamicClaims covered that case.

We don't want an admin that we demote to a simple guest to still have admin powers for an hour and thought it should be working out of the box.

This is issue is noticeable in our blazor app and our maui blazor hybrid mobile app.

We tried adding a middleware in identity service to replace the claims by the current role claims but it didn't work.

Do you have any suggestions?

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

13 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you test this in a new microservice solution?

    If it still not working, Please share your steps.

    Thanks.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    aziz.bouhejba created

    yes done that, same issue

    Reproduction Steps:

    1. Create a new microservice solution.
    2. Create a new tenant.
    3. Log in as the tenant admin.
    4. Create a new role called "Guest".
    5. Create a user named "TestUser" and assign the "Admin" role.
    6. Open an incognito browser and log in as TestUser.
    7. Confirm that TestUser has admin privileges — ✅ expected.
    8. Log out TestUser.
    9. As admin, modify TestUser’s role to "Guest" (remove admin role).
    10. Log in again as TestUser (in incognito).
    11. TestUser still has admin privileges — ❌ unexpected.

    Expected Behavior:

    After logging out and back in, TestUser should have Guest permissions only, with admin privileges revoked. According to the ABP documentation, role changes should take effect at the next request or at least after reauthentication. For us it doesn't even work with a logout/login

    Actual Behavior:

    Role changes are not applied even after logout/login. It seems role claims are cached or not refreshed properly.

    Only solution we found right now is creating a redis cache service and deleting user cache (not ideal)..

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I will check your steps. Thanks.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you try to depend on AbpIdentityProEntityFrameworkCoreModule in AdministrationService?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    aziz.bouhejba created

    yes it works.. thank you. I guess it's a template issue then?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Yes, I will update the template code.

    Thanks.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Instead of adding AbpIdentityProEntityFrameworkCoreModule in AdministrationService

    Can you try to configure the WebRemoteDynamicClaimsPrincipalContributorOptions in AdministrationService?

    Thanks.

    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        PreConfigure<WebRemoteDynamicClaimsPrincipalContributorOptions>(options =>
        {
            options.IsEnabled = true;
        });
    }
    

    Also please depends on the typeof(AbpAspNetCoreAuthenticationJwtBearerModule) in AdministrationService .

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    aziz.bouhejba created

    Hi!

    tried the new proposed solution, doesn't work on our Blazor Web app. both proposed solutions also don't work for our MAUI Blazor hybrid mobile app.

    We need the dynamic claims to also work on mobile app.

    Thank you

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Have you added the AbpAspNetCoreAuthenticationJwtBearerModule in AdministrationService?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    aziz.bouhejba created

    yes I did

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    But I couldn't reproduce the problem in a new microservice template after configuring WebRemoteDynamicClaimsPrincipalContributorOptions.

    The dynamic claims works.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    aziz.bouhejba created

    results on our end:

    • Blazor web app : works fine
    • MAUI Blazor hybrid app : works fine locally / when deployed on the android-apple stores, doesn't work.

    We are gonna try a custom solution to clear redis cache of user because we have no time dealing with this..

    Our Redis cache solution works

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    MAUI Blazor hybrid app : works fine locally / when deployed on the android-apple stores, doesn't work.

    If you refresh the maui page. Does it works?

    We recently added a MauiCurrentApplicationConfigurationCacheResetService. Can you try to add it to your Maui project and override the MauiBlazorCachedApplicationConfigurationClient?

    https://github.com/abpframework/abp/pull/22866/files

    Thanks.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.