/// <inheritdoc/>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var envSettings = filterContext.HttpContext.RequestServices.GetService <IEnvSettings>();

            if (!envSettings.IsDebug)
            {
                filterContext.Result = ErrorObjectResultFactory.Forbidden();
                return;
            }
            base.OnActionExecuting(filterContext);
        }
        /// <inheritdoc/>
        protected override async Task HandleForbiddenAsync(AuthenticationProperties properties)
        {
            var    options = Context.RequestServices.GetService <IOptions <JsonOptions> >();
            var    result  = ErrorObjectResultFactory.Forbidden();
            string json    = JsonSerializer.Serialize(result.Value, options.Value.JsonSerializerOptions);

            Response.Headers["WWW-Authenticate"] = "Bearer error=\"insufficient_scope\"";
            Response.StatusCode  = result.StatusCode.Value;
            Response.ContentType = "application/json";
            await Response.BodyWriter.WriteAsync(Encoding.UTF8.GetBytes(json));
        }