Open Closed

PermissionValueProvider - [ERR] The method or operation is not implemented. #918


User avatar
0
Mohammad created

How to implement the below method?

The docs doesn't provide any example. https://docs.abp.io/en/abp/4.1/Authorization

public override Task<MultiplePermissionGrantResult> CheckAsync(PermissionValuesCheckContext context)
public class EntitiesPermissionValueProvider : PermissionValueProvider
    {
        public override string Name => "UE";

        public EntitiesPermissionValueProvider(IPermissionStore permissionStore)
        : base(permissionStore)
        {
        }

        public async override Task<PermissionGrantResult>
           CheckAsync(PermissionValueCheckContext context)
        {
            if (context.Principal?.FindFirst("User_Type")?.Value == "SystemAdmin")
            {
                return PermissionGrantResult.Granted;
            }

            return PermissionGrantResult.Undefined;
        }

        public override Task<MultiplePermissionGrantResult> CheckAsync(PermissionValuesCheckContext context)
        {
            throw new NotImplementedException();
        }
    }

ERR] The method or operation is not implemented. System.NotImplementedException: The method or operation is not implemented. at Zenithr.Intelligence.Permissions.EntitiesPermissionValueProvider.CheckAsync(PermissionValuesCheckContext context) in C:\websites\ZENITHR3.0\modules\intelligence\src\Zenithr.Intelligence.Application.Contracts\Permissions\EntitiesPermissionValueProvider.cs:line 32 at Volo.Abp.Authorization.Permissions.PermissionChecker.IsGrantedAsync(ClaimsPrincipal claimsPrincipal, String[] names) at Volo.Abp.Authorization.Permissions.PermissionChecker.IsGrantedAsync(String[] names) at Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationAppService.GetAuthConfigAsync() at Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationAppService.GetAsync() at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync() at lambda_method1435(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(ControllerActionInvoker invoker)

at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)`


Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
  • ABP Framework version: v4.1.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:

2 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Try

    public class EntitiesPermissionValueProvider : PermissionValueProvider
    {
        public override string Name => "UE";
    
        public EntitiesPermissionValueProvider(IPermissionStore permissionStore)
        : base(permissionStore)
        {
        }
    
        public override Task<PermissionGrantResult> CheckAsync(PermissionValueCheckContext context)
        {
            if (CheckAsync(context.Principal))
            {
                return Task.FromResult(PermissionGrantResult.Granted);
            }
    
            return Task.FromResult(PermissionGrantResult.Undefined);
        }
    
        public override Task<MultiplePermissionGrantResult> CheckAsync(PermissionValuesCheckContext context)
        {
            var permissionNames = context.Permissions.Select(x => x.Name).ToArray();
    
            if (CheckAsync(context.Principal))
            {
                return Task.FromResult(new MultiplePermissionGrantResult(permissionNames, PermissionGrantResult.Granted));
            }
    
            return Task.FromResult(new MultiplePermissionGrantResult(permissionNames, PermissionGrantResult.Undefined));
        }
    
        private bool CheckAsync(ClaimsPrincipal principal)
        {
            return principal?.FindFirst("User_Type")?.Value == "SystemAdmin";
        }
    }
    
  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 05, 2024, 12:19