/// <summary> /// Called when request is received. /// </summary> /// <param name="context">The action context.</param> /// <param name="next">The next delegate.</param> /// <returns>Task tracking async operation.</returns> public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { var activities = TenantFiltering.GetActivities(context.ActionArguments); if (activities.Any(activity => !tenantFiltering.IsFromAllowedTenant(activity))) { context.Result = new StatusCodeResult((int)HttpStatusCode.Forbidden); } else { await next(); } }
/// <summary> /// Called when request is received. /// </summary> /// <param name="actionContext">The action context.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task tracking operation.</returns> public override async Task OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken) { if (tenantFiltering != null) { await base.OnActionExecutingAsync(actionContext, cancellationToken); var activities = TenantFiltering.GetActivities(actionContext.ActionArguments); if (activities.Any()) { if (!tenantFiltering.IsFromAllowedTenant(activities.First())) { actionContext.Response = new HttpResponseMessage(HttpStatusCode.Forbidden); } } } }