public override void OnActionExecuting(ActionExecutingContext filterContext) { DivvyManager.Init(); // This will immediately return if Init has already occured // If Divvy is disabled, no one is getting in if (DivvyManager.Settings.Mode == DivvyMode.Disabled) { DivvyLogManager.Log("Divvy Integration Not Enabled. Aborting."); filterContext.Result = new HttpStatusCodeResult(HttpStatusCode.Forbidden, "Divvy disabled. Divvy integration is installed but not enabled in this Episerver instance."); return; // Reject } // If they're logged into the debug role, they're good... if (DivvyManager.Settings.DebugRole != null && filterContext.HttpContext.User.IsInRole(DivvyManager.Settings.DebugRole)) { return; // Allow } // If their auth token validated, they're good var result = DivvyAccessToken.Validate(); if (result.Authorized) { return; // Allow } DivvyLogManager.Log(result.Message); filterContext.Result = new HttpUnauthorizedResult(result.Message); return; // Default reject everything that gets here }
public JsonResult Gateway() { if (DivvyManager.Settings.LogRequestDebugData) { DivvyLogManager.Log("Gateway Request Started", new { RequestKey = DivvyLogManager.GetRequestLogKey() }); } var requestBody = GetRequestBody(); var responseBody = DivvyManager.ProcessDivvyInput(requestBody); if (DivvyManager.Settings.LogRequestDebugData) { DivvyLogManager.Log("Gateway Request Ended"); } return(Json(responseBody)); }