public override Task Invoke(IOwinContext context)
 {
     foreach (var filter in _options.Authorization)
     {
         if (!filter.Authorize(context.Request))
         {
             context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
             return(context.Response.WriteAsync("401 Unauthorized"));
         }
     }
     context.Response.ContentType = Constants.ContentType;
     return(context.Response.WriteAsync(CLRStatsService.GetCurrentCLRStatsToJson()));
 }
Esempio n. 2
0
        public Task Invoke(HttpContext httpContext)
        {
            foreach (var filter in _options.Authorization)
            {
                if (!filter.Authorize(httpContext.Request))
                {
                    var isAuthenticated = httpContext.User?.Identity?.IsAuthenticated;

                    httpContext.Response.StatusCode = isAuthenticated == true
                        ? (int)HttpStatusCode.Forbidden
                        : (int)HttpStatusCode.Unauthorized;
                    return(Task.CompletedTask);
                }
            }
            httpContext.Response.ContentType = Constants.ContentType;
            return(httpContext.Response.WriteAsync(CLRStatsService.GetCurrentCLRStatsToJson()));
        }