Exemplo n.º 1
0
 /// <summary>
 /// Invoke the specified context and next.
 /// </summary>
 /// <returns>The invoke.</returns>
 /// <param name="context">Context.</param>
 /// <param name="next">Next.</param>
 public async override Task Invoke(AspectContext context, AspectDelegate next)
 {
     if (Aspects.CrossCuttingConcerns.IsApplied(context.Implementation, Concern))
     {
         await next(context);
         return;
     }
     GetPermission(context);
     var service = context.ServiceProvider.GetRequiredService<IAuthorizationService>();
     var authorizationContext = new InvocationAuthorizationContext(Permissions, RequireAllPermissions, context.ServiceMethod);
     await service.CheckAsync(authorizationContext);
     await next(context);
 }
Exemplo n.º 2
0
 public async Task AuthorizeAsync(bool requireAllPermissions, params string[] permissions)
 {
     var service = _serviceProvider.GetRequiredService <IAuthorizationService>();
     var authorizationContext = new InvocationAuthorizationContext(permissions, requireAllPermissions, null);
     await service.CheckAsync(authorizationContext);
 }