Giter Site home page Giter Site logo

Comments (16)

alihdev avatar alihdev commented on July 18, 2024 1

We'll work on creating a project that highlights the issue

from eshoponabp.

alihdev avatar alihdev commented on July 18, 2024 1

Hello,

While debugging the ABP code, we've discovered that when the cache is cleared or a role is assigned to a user from the X service, the admin service isn't affected. However, when we clear the cache from the admin service, everything works fine.

Please refer to this video for a clearer understanding of the issue: Video Link

Additionally, we've created a project for your review to investigate the problem: Project Link

Please note the changes we've made in the latest version of eShop code:

  • Permission creation from CmskitService: Code Link

  • Dynamic permission enablement in AdministrationService: Code Link

Your assistance in resolving this matter is greatly appreciated.

Thank you!

from eshoponabp.

maliming avatar maliming commented on July 18, 2024 1

hi

You can inject the IDistributedCache DistributedCache and remove the $"{CacheOptions.KeyPrefix}_AbpInMemoryPermissionCacheStamp"; cache.

I will find a way on the framework.

from eshoponabp.

alihdev avatar alihdev commented on July 18, 2024 1

Ok, I tried this, and the cache cleared successfully.

However, I encountered another issue when attempting to call this function from X service:

  await _permissionManager.SetForRoleAsync("admin", name, true);

We've discovered that we should also enable the IsDynamicPermissionStoreEnabled configuration in the X service when we activate it. We're encountering the following exceptions within the PermissionManager

ManagementProviders 
(Autofac.Core.DependencyResolutionException: An exception was thrown while activating Volo.Abp.PermissionManagement.Identity.RolePermissionManagementProvider. ---> Autofac.Core.DependencyResolutionException: None of the constructors found on type 'Volo.A…):
[humanresource-service_3e0ba3d1-e]: [13:39:17 WRN] An exception occurred, but response has already started!
[humanresource-service_3e0ba3d1-e]: [13:39:17 ERR] An unhandled exception has occurred while executing the request.
[humanresource-service_3e0ba3d1-e]: Autofac.Core.DependencyResolutionException: An exception was thrown while activating Volo.Abp.PermissionManagement.Identity.RolePermissionManagementProvider.
[humanresource-service_3e0ba3d1-e]: ---> Autofac.Core.DependencyResolutionException: None of the constructors found on type 'Volo.Abp.PermissionManagement.Identity.RolePermissionManagementProvider' can be invoked with the available services and parameters:
[humanresource-service_3e0ba3d1-e]: Cannot resolve parameter 'Volo.Abp.Identity.IUserRoleFinder userRoleFinder' of constructor 'Void .ctor(Volo.Abp.PermissionManagement.IPermissionGrantRepository, Volo.Abp.Guids.IGuidGenerator, Volo.Abp.MultiTenancy.ICurrentTenant, Volo.Abp.Identity.IUserRoleFinder)'.
[humanresource-service_3e0ba3d1-e]:
[humanresource-service_3e0ba3d1-e]: See https://autofac.rtfd.io/help/no-constructors-bindable for more info.
[humanresource-service_3e0ba3d1-e]: at Autofac.Core.Activators.Reflection.ReflectionActivator.<>c__DisplayClass14_0.<UseSingleConstructorActivation>b__0(ResolveRequestContext ctxt, Action`1 next)
[humanresource-service_3e0ba3d1-e]: at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
[humanresource-service_3e0ba3d1-e]: at Autofac.Builder.RegistrationBuilder`3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext ctxt, Action`1 next)
[humanresource-service_3e0ba3d1-e]: at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)

Also, here's an image related to the code issue:

image

I will reproduce this issue in the public project

Thank you!

from eshoponabp.

alihdev avatar alihdev commented on July 18, 2024 1

Related to the above comment, I have fixed it; there was a dependency issue in the host (AbpIdentityHttpApiClientModule).

from eshoponabp.

maliming avatar maliming commented on July 18, 2024 1

abpframework/abp#18628

from eshoponabp.

maliming avatar maliming commented on July 18, 2024

However, the issue arises when we call the application configuration endpoint; to get permissions .. the newly added permissions don't appear unless we rebuild the AdministrationService.

You can wait for 30 seconds to refresh the memory cache.

https://github.com/abpframework/abp/blob/dev/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/DynamicPermissionDefinitionStore.cs#L92

from eshoponabp.

alihdev avatar alihdev commented on July 18, 2024

Hello,

Thank you for your prompt response. the refresh isn't happening even after waiting for more than 30 seconds.

Regarding our code to clear the cache:

protected virtual Task ClearStoreCacheAsync()
{
    _storeCache.LastCheckTime = null;
    _storeCache.CacheStamp = null;

    return Task.CompletedTask;
}

We're calling this code after inserting new permissions.

Do you have any further insights into why the cache might not be refreshing as expected?

Thank you.

from eshoponabp.

maliming avatar maliming commented on July 18, 2024

hi

Can you share a project to show this problem? You can upload it to GitHub.

from eshoponabp.

maliming avatar maliming commented on July 18, 2024

hi

Can you update your tye.yaml file and share the steps to reproduce?

I have some doubts about running your app and authentication.

from eshoponabp.

alihdev avatar alihdev commented on July 18, 2024

The project I shared with you is the same as eShopOnAbp. I downloaded it, and we've made the following changes:

Please note the changes we've made in the latest version of eShop code:

  • Permission creation from CmskitService: Code Link
  • Dynamic permission enablement in AdministrationService: Code Link

Additionally, we modified the type.yml to only run the cmskit-service and administration-service, similar to the setup in tye.yaml. You can use it.

from eshoponabp.

maliming avatar maliming commented on July 18, 2024

I will run the run-tye.ps1, What are the next steps?

from eshoponabp.

alihdev avatar alihdev commented on July 18, 2024

When the gateway is open, please open two tabs: one for the administration-service and another for the cmskit-service.

In the cmskit-service Swagger, call the endpoint CreatePermission in SimpleAppService to create dynamic permissions.
Subsequently,
In administration-service Swagger, call the endpoint Get in AbpApplicationConfigurationAppService to retrieve the current user with their permissions.

You'll notice that the permission (created in CreatePermission) is not found only after you rebuild the admin service.

Further details can be found in the commmet

from eshoponabp.

maliming avatar maliming commented on July 18, 2024

hi

You can inject the IDistributedCache DistributedCache and remove the $"{CacheOptions.KeyPrefix}_AbpInMemoryPermissionCacheStamp"; cache.

I will find a way on the framework.

hi

I checked the source code.

The StaticPermissionSaver will update the cache value. Can you try to debug this class to see what's happened?

https://github.com/abpframework/abp/blob/dev/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/StaticPermissionSaver.cs#L116-L123

from eshoponabp.

StevenNgoc avatar StevenNgoc commented on July 18, 2024

@maliming Please help me !
I run demo eShopOnAbp in local. I find a problem !
When update Permission with Module Permission-Manager.

  1. In Roles menu, update permission then menu can auto render in SideMenuLayoutModule
  2. But in Users menu, it cant auto render.

I check in Caching Service with Redis. R,pk have update, but U,pk is not.
I did review code in Abp and Permission Module. Fuction update Role and User permission is the same api.
Please help me why permission it not update in caching

from eshoponabp.

maliming avatar maliming commented on July 18, 2024

hi @StevenNgoc

Please create a new issue, and share the steps.

Thanks.

from eshoponabp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.