Add redirect to HTTPS option

Summary: Rehash of D3411. In cgi/fcgi setups we have no idea if the request is HTTP or HTTPS as far as I can tell, so make this config-triggered again. Also handle @vrana's "off" case.

Test Plan: Set this flag, observed redirect to https when `$_SERVER['HTTPS']` was absent.

Reviewers: nh, vrana

Reviewed By: nh

CC: aran

Differential Revision: https://secure.phabricator.com/D3420
This commit is contained in:
epriestley
2012-09-04 09:56:30 -07:00
parent e3c6dc687a
commit ee05fe81a4
3 changed files with 38 additions and 0 deletions

View File

@@ -119,6 +119,15 @@ abstract class AphrontApplicationConfiguration {
$request = $this->getRequest();
$path = $request->getPath();
if (PhabricatorEnv::getEnvConfig('security.require-https')) {
if (!$request->isHTTPS()) {
$uri = $request->getRequestURI();
$uri->setDomain($request->getHost());
$uri->setProtocol('https');
return $this->buildRedirectController($uri);
}
}
list($controller, $uri_data) = $this->buildControllerForPath($path);
if (!$controller) {
if (!preg_match('@/$@', $path)) {