From 8afc7fc2cd6d108bb5d34467eec87e581df4247b Mon Sep 17 00:00:00 2001 From: Nick Harper Date: Thu, 30 Aug 2012 16:11:23 -0700 Subject: [PATCH] Redirect to https Summary: If the phabricator.base-uri is set up with https and phabricator receives a request that isn't over ssl, we will issue a redirect response to the user to force them to use https. Test Plan: With this disabled, verified that pages still load correctly over http. Enabled it; verified I get redirected to the same path but on https when I make an http request; verified https requests get served without a redirect. Reviewers: epriestley, vrana Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3411 --- .../configuration/AphrontApplicationConfiguration.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/aphront/configuration/AphrontApplicationConfiguration.php b/src/aphront/configuration/AphrontApplicationConfiguration.php index bc0ec5e99f..b82e0e8983 100644 --- a/src/aphront/configuration/AphrontApplicationConfiguration.php +++ b/src/aphront/configuration/AphrontApplicationConfiguration.php @@ -119,6 +119,14 @@ abstract class AphrontApplicationConfiguration { $request = $this->getRequest(); $path = $request->getPath(); + // Check if we should do an HTTP -> HTTPS redirect + $base_uri = new PhutilURI( + PhabricatorEnv::getEnvConfig('phabricator.base-uri')); + if ($base_uri->getProtocol() === 'https' && !$_SERVER['HTTPS']) { + $base_uri->setPath($path); + return $this->buildRedirectController($base_uri); + } + list($controller, $uri_data) = $this->buildControllerForPath($path); if (!$controller) { if (!preg_match('@/$@', $path)) {