Open Closed

WPF using the predefined ClientProxies and permission definitions. #3571


User avatar
0
jeffbuot created
  • ABP Framework version: v5.3.3
  • UI type: Blazor
  • DB provider:MongoDB

I have a microservice backend and WPF as client application. I'm using client proxy for fetching data from backend, my concern is sometimes I'm struggling to find the existing ClientProxies and finding the permissions definition for template services.

  • Are there a list of predefined clientproxies for me to have a CRUD for administration area like roles,users, audit logs
  • Are there a list of predefined constant string variable for policy names? If so what are the right class or property I should call? Is there a list? (I know that you can get policy names from swagger abpappconfiguration)
  • IAuthorizationService is always returning false even if the current logged user is admin
[DependsOn(typeof(AdministrationServiceHttpApiClientModule))]
public class AdministrationServiceWpfModule : AbpModule{
...
}
...
var auth = ServiceCollection.GetRequiredService<IAuthorizationService>();
var result = await  auth.IsGrantedAsync("AbpIdentity.Users");
//result is always false

14 Answer(s)
  • User Avatar
    0
    jeffbuot created

    Hi,

    It's been more than 24 hours. I also haven't resolve the issue yet. Is there anyone available to assist?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I'm using client proxy

    What is the client type are you using? Static or dynamic?

    https://docs.abp.io/en/abp/latest/API/Static-CSharp-API-Clients https://docs.abp.io/en/abp/latest/API/Dynamic-CSharp-API-Clients

  • User Avatar
    0
    jeffbuot created

    It's dynamic since I'm using administration, identity http client modules that is using AddHttpClientProxies.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Are there a list of predefined clientproxies for me to have a CRUD for administration area like roles,users, audit logs

    You just need to use the AppServices to CRUD.

    Are there a list of predefined constant string variable for policy names? If so what are the right class or property I should call? Is there a list? (I know that you can get policy names from swagger abpappconfiguration)

    No, They are existing in the XXX.Application.Constract modules.

    IAuthorizationService is always returning false even if the current logged user is admin

    Can you try to depends on the AbpAspNetCoreMvcClientModule?

  • User Avatar
    0
    jeffbuot created

    I'm in a microservice project can I know what AppService I need to use to check permission grants?

  • User Avatar
    0
    jeffbuot created

    Using IPermissionStore is giving me NullPermissionStore

    Using IAuthorizationService gives me no ClaimsPrincipal

  • User Avatar
    0
    jeffbuot created

    Can you try to depends on the AbpAspNetCoreMvcClientModule?

    Gave me exception:

    Autofac.Core.DependencyResolutionException: An exception was thrown while activating CMVPoint.AdministrationService.Wpf.ViewModels.UsersViewModel -> Volo.Abp.Authorization.AbpAuthorizationService -> Microsoft.AspNetCore.Authorization.DefaultAuthorizationHandlerProvider -> λ:Microsoft.AspNetCore.Authorization.IAuthorizationHandler[] -> Volo.Abp.Authorization.PermissionRequirementHandler -> Volo.Abp.AspNetCore.Mvc.Client.RemotePermissionChecker -> Volo.Abp.AspNetCore.Mvc.Client.MvcCachedApplicationConfigurationClient.
     ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Volo.Abp.AspNetCore.Mvc.Client.MvcCachedApplicationConfigurationClient' can be invoked with the available services and parameters:
    Cannot resolve parameter 'Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor' of constructor 'Void .ctor(Volo.Abp.Caching.IDistributedCache`1[Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto], Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ClientProxies.AbpApplicationConfigurationClientProxy, Volo.Abp.Users.ICurrentUser, Microsoft.AspNetCore.Http.IHttpContextAccessor)'.
       at Autofac.Core.Activators.Reflection.ReflectionActivator.GetAllBindings(ConstructorBinder[] availableConstructors, IComponentContext context, IEnumerable`1 parameters)
       at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
       at Autofac.Core.Activators.Reflection.ReflectionActivator.&lt;ConfigurePipeline&gt;b__11_0(ResolveRequestContext ctxt, Action`1 next)
       at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
       at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
       at Autofac.Builder.RegistrationBuilder`3.&lt;&gt;c__DisplayClass41_0.&lt;PropertiesAutowired&gt;b__0(ResolveRequestContext ctxt, Action`1 next)
       at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
       at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       --- End of inner exception stack trace ---
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I realize you don't need to check permissions in WPF, The AppService will check permissions automatically.

    Also no longer need the AbpAspNetCoreMvcClientModule

    You only need to use the app services to call the method.

  • User Avatar
    0
    jeffbuot created

    In our case we need to check the permission because we are hiding some controls/navigations if the current user is not granted from a specific policy.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    You can use the IAbpApplicationConfigurationAppService and get the ApplicationConfigurationDto

    Permissions and other info will exist in the DTO,

  • User Avatar
    0
    jeffbuot created

    What module should I add to depends on?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    AbpAspNetCoreMvcClientCommonModule

  • User Avatar
    0
    jeffbuot created

    Hi, I did but I got this exception:

    Autofac.Core.DependencyResolutionException: An exception was thrown while activating CMVPoint.AdministrationService.Wpf.ViewModels.UsersViewModel.
     ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'CMVPoint.AdministrationService.Wpf.ViewModels.UsersViewModel' can be invoked with the available services and parameters:
    Cannot resolve parameter 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.IAbpApplicationConfigurationAppService abpConfig' of constructor 'Void .ctor(CMVPoint.Shared.Wpf.AccessTokenManager, Microsoft.Extensions.Logging.ILogger`1[CMVPoint.AdministrationService.Wpf.ViewModels.UsersViewModel], Volo.Abp.EventBus.Local.ILocalEventBus, Volo.Abp.PermissionManagement.ClientProxies.PermissionsClientProxy, Volo.Abp.Identity.ClientProxies.IdentityUserClientProxy, Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ClientProxies.AbpApplicationConfigurationClientProxy, Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.IAbpApplicationConfigurationAppService)'.
       at Autofac.Core.Activators.Reflection.ReflectionActivator.GetAllBindings(ConstructorBinder[] availableConstructors, IComponentContext context, IEnumerable`1 parameters)
       at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
       at Autofac.Core.Activators.Reflection.ReflectionActivator.&lt;ConfigurePipeline&gt;b__11_0(ResolveRequestContext ctxt, Action`1 next)
       at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
       at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
       at Autofac.Builder.RegistrationBuilder`3.&lt;&gt;c__DisplayClass41_0.&lt;PropertiesAutowired&gt;b__0(ResolveRequestContext ctxt, Action`1 next)
       at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
       at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       --- End of inner exception stack trace ---
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Try to use AbpApplicationConfigurationClientProxy

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11