protected void Application_BeginRequest(object sender, EventArgs e) { if (!applicationStarted) { lock (locker) { if (!applicationStarted) { applicationStarted = true; Application_StartDelayed(sender, e); } } } var currentTenant = CoreContext.TenantManager.GetCurrentTenant(false); if (currentTenant == null) { var redirectUrl = String.Format("{0}?url={1}", SetupInfo.NoTenantRedirectURL, Request.Url.Host); Response.Redirect(redirectUrl, true); } else if (currentTenant.Status != TenantStatus.Active) { var ind = Request.Url.AbsoluteUri.IndexOf(VirtualPathUtility.ToAbsolute("~/confirm.aspx"), StringComparison.InvariantCultureIgnoreCase); if (currentTenant.Status == TenantStatus.Transfering) { var errorRegexPattern = ConfigurationManager.AppSettings["web.transfering.errorstatus-regex"]; if (!string.IsNullOrEmpty(errorRegexPattern) && Regex.IsMatch(Request.Url.AbsoluteUri, errorRegexPattern)) { Response.StatusCode = (int)HttpStatusCode.ServiceUnavailable; Response.End(); } else { Response.Redirect(SetupInfo.TenantTransferingRedirectURL, true); } } else if (currentTenant.Status == TenantStatus.RemovePending || !(ind >= 0 && currentTenant.Status == TenantStatus.Suspended)) { var redirectUrl = String.Format("{0}?url={1}", SetupInfo.NoTenantRedirectURL, Request.Url.Host); Response.Redirect(redirectUrl, true); } } if (!CheckBasicAuth(((HttpApplication)sender).Context)) { WebStudioCommonModule.Authenticate(); } WebStudioCommonModule.ResolveUserCulture(); FixFlashPlayerCookieBug(); }
private bool AjaxCheckMethodPermissions(MethodInfo method) { var authorized = SecurityContext.IsAuthenticated; if (!authorized && HttpContext.Current != null) { authorized = method.GetCustomAttributes(typeof(SecurityAttribute), true) .Cast <SecurityAttribute>() .Any(a => a.CheckAuthorization(HttpContext.Current)); if (!authorized) { authorized = WebStudioCommonModule.Authenticate(); } } return(authorized); }
protected void Application_BeginRequest(object sender, EventArgs e) { if (!applicationStarted) { lock (locker) { if (!applicationStarted) { applicationStarted = true; Application_StartDelayed(); } } } var currentTenant = CoreContext.TenantManager.GetCurrentTenant(false); if (currentTenant == null) { var redirectUrl = String.Format("{0}?url={1}", SetupInfo.NoTenantRedirectURL, Request.Url.Host); Response.Redirect(redirectUrl, true); } else if (currentTenant.Status != TenantStatus.Active) { var ind = Request.Url.AbsoluteUri.IndexOf(VirtualPathUtility.ToAbsolute("~/confirm.aspx"), StringComparison.InvariantCultureIgnoreCase); if (currentTenant.Status == TenantStatus.Transfering || currentTenant.Status == TenantStatus.Restoring) { // allow requests to backup handler to get access to the GetRestoreStatus method var handlerType = typeof(BackupAjaxHandler); var backupHandler = handlerType.FullName + "," + handlerType.Assembly.GetName().Name + ".ashx"; var allowedRequests = new[] { backupHandler, "migration-portal.htm" }; if (!allowedRequests.Any(path => Request.Url.AbsolutePath.EndsWith(path, StringComparison.InvariantCultureIgnoreCase))) { //requests to APIs should end with error status var apiUrlRegex = new Regex("^" + SetupInfo.WebApiBaseUrl + @"|\.ashx$" + @"|^/products/files/services/wcfservice/service.svc", RegexOptions.IgnoreCase | RegexOptions.Compiled); if (apiUrlRegex.IsMatch(Request.Url.AbsolutePath)) { Response.StatusCode = (int)HttpStatusCode.ServiceUnavailable; Response.End(); } Response.Redirect("~/migration-portal.htm", true); } } else if (currentTenant.Status == TenantStatus.RemovePending || !(ind >= 0 && currentTenant.Status == TenantStatus.Suspended)) { var redirectUrl = String.Format("{0}?url={1}", SetupInfo.NoTenantRedirectURL, Request.Url.Host); Response.Redirect(redirectUrl, true); } } if (!SecurityContext.IsAuthenticated) { if (!CheckBasicAuth(((HttpApplication)sender).Context)) { WebStudioCommonModule.Authenticate(); } } WebStudioCommonModule.ResolveUserCulture(); FixFlashPlayerCookieBug(); }