/// <summary> /// This method authorize access bases on context and requirement /// Is triggered by annotation on MVC action and setup in startup. /// </summary> /// <param name="context">The context</param> /// <param name="requirement">The requirement</param> /// <returns>A Task</returns> protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, AppAccessRequirement requirement) { if (_pepSettings.DisablePEP) { context.Succeed(requirement); return; } XacmlJsonRequestRoot request = DecisionHelper.CreateXacmlJsonRequestRoot(context, requirement, _httpContextAccessor.HttpContext.GetRouteData()); XacmlJsonResponse response = await _pdp.GetDecisionForRequest(request); if (response?.Response == null) { throw new ArgumentNullException("response"); } if (!DecisionHelper.ValidateResponse(response.Response, context.User)) { context.Fail(); } context.Succeed(requirement); await Task.CompletedTask; }