Disabling SSL enforcers was a REALLY bad idea. Adding special case for CloudFlare instead - it's a common enough deployment.

This commit is contained in:
Rick Falkvinge
2014-09-08 19:23:47 +00:00
parent 6eba31c786
commit 7370b34fdb
2 changed files with 13 additions and 7 deletions
+6 -3
View File
@@ -61,8 +61,11 @@ namespace Swarmops
// Check for SSL and force it
/* DISABLED - WORKS REALLY POORLY WHEN IN COMPLEX DEPLOYMENTS. MUST IMPROVE DETECTION MECHANISM
if (Request.Url.ToString().StartsWith("http://")) // only check client-side as many server sites de-SSL the connection before reaching the web server
string cloudFlareVisitorScheme = Request.Headers["CF-Visitor"];
bool cloudFlareSsl = (cloudFlareVisitorScheme == "\"scheme\":\"https\""? true: false);
if (Request.Url.ToString().StartsWith("http://") && !cloudFlareSsl) // only check client-side as many server sites de-SSL the connection before reaching the web server
{
if (!Request.Url.ToString().StartsWith("http://dev.swarmops.com/") && !Request.Url.ToString().StartsWith("http://sandbox.swarmops.com") && !Request.Url.ToString().StartsWith("http://localhost:") && !Request.Url.ToString().StartsWith("http://swarmops-"))
{
@@ -71,7 +74,7 @@ namespace Swarmops
// Only force this if set to force it in database
// TODO: Make admin init task
}
}*/
}
Localize();
+7 -4
View File
@@ -30,16 +30,19 @@ namespace Swarmops.Pages.Security
this.LabelLoginFailed.Visible = false;
this.TextLogin.Focus();
// Check for SSL
// Check for SSL and force it
/* DISABLE temporarily
if ((!Request.IsSecureConnection) && (!Request.Url.ToString().StartsWith("https://"))) // Both are necessary, as some reverse proxies will https-ify an original nonsecure connection
string cloudFlareVisitorScheme = Request.Headers["CF-Visitor"];
bool cloudFlareSsl = (cloudFlareVisitorScheme == "\"scheme\":\"https\""? true: false);
if (Request.Url.ToString().StartsWith("http://") && !cloudFlareSsl) // only check client-side as many server sites de-SSL the connection before reaching the web server
{
if (!Request.Url.ToString().StartsWith("http://dev.swarmops.com/") && !Request.Url.ToString().StartsWith("http://localhost:") && !Request.Url.ToString().StartsWith("http://swarmops-"))
{
Response.Redirect(Request.Url.ToString().Replace("http:", "https:"));
}
} */
}
}
protected void ButtonLogin_Click(object sender, EventArgs e)