diff --git a/src/aphront/configuration/AphrontApplicationConfiguration.php b/src/aphront/configuration/AphrontApplicationConfiguration.php index 4e71a29c7b..8f353282ae 100644 --- a/src/aphront/configuration/AphrontApplicationConfiguration.php +++ b/src/aphront/configuration/AphrontApplicationConfiguration.php @@ -120,6 +120,7 @@ abstract class AphrontApplicationConfiguration { $file_uri = PhabricatorEnv::getEnvConfig( 'security.alternate-file-domain'); $conduit_uris = PhabricatorEnv::getEnvConfig('conduit.servers'); + $allowed_uris = PhabricatorEnv::getEnvConfig('phabricator.allowed-uris'); $uris = array_merge( array( @@ -127,7 +128,8 @@ abstract class AphrontApplicationConfiguration { $prod_uri, $file_uri, ), - $conduit_uris); + $conduit_uris, + $allowed_uris); $host_match = false; foreach ($uris as $uri) { diff --git a/src/applications/config/option/PhabricatorCoreConfigOptions.php b/src/applications/config/option/PhabricatorCoreConfigOptions.php index 053c5d1390..1d2e34167d 100644 --- a/src/applications/config/option/PhabricatorCoreConfigOptions.php +++ b/src/applications/config/option/PhabricatorCoreConfigOptions.php @@ -37,6 +37,19 @@ final class PhabricatorCoreConfigOptions "{{phabricator.base-uri}}. Most installs do not need to set ". "this option.")) ->addExample('http://phabricator.example.com/', pht('Valid Setting')), + $this->newOption('phabricator.allowed-uris', 'list', array()) + ->setLocked(true) + ->setSummary(pht("Alternative URIs that can access Phabricator.")) + ->setDescription( + pht( + "These alternative URIs will be able to access 'normal' pages ". + "on your Phabricator install. Other features such as OAuth ". + "won't work. The major use case for this is moving installs ". + "across domains.")) + ->addExample( + '["http://phabricator2.example.com/", '. + '"http://phabricator3.example.com/]"', + pht('Valid Setting')), $this->newOption('phabricator.timezone', 'string', null) ->setSummary( pht("The timezone Phabricator should use.")) diff --git a/src/applications/differential/field/specification/DifferentialRevisionIDFieldSpecification.php b/src/applications/differential/field/specification/DifferentialRevisionIDFieldSpecification.php index 3e341c25e9..2703386953 100644 --- a/src/applications/differential/field/specification/DifferentialRevisionIDFieldSpecification.php +++ b/src/applications/differential/field/specification/DifferentialRevisionIDFieldSpecification.php @@ -71,6 +71,14 @@ final class DifferentialRevisionIDFieldSpecification if ($uri == PhabricatorEnv::getProductionURI('/D'.$id)) { return $id; } + + $allowed_uris = PhabricatorEnv::getAllowedURIs('/D'.$id); + + foreach ($allowed_uris as $allowed_uri) { + if ($uri == $allowed_uri) { + return $id; + } + } } return null; diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php index 1cad3d4f12..a9ed3571b0 100644 --- a/src/infrastructure/env/PhabricatorEnv.php +++ b/src/infrastructure/env/PhabricatorEnv.php @@ -278,6 +278,21 @@ final class PhabricatorEnv { return rtrim($production_domain, '/').$path; } + public static function getAllowedURIs($path) { + $uri = new PhutilURI($path); + if ($uri->getDomain()) { + return $path; + } + + $allowed_uris = self::getEnvConfig('phabricator.allowed-uris'); + $return = array(); + foreach ($allowed_uris as $allowed_uri) { + $return[] = rtrim($allowed_uri, '/').$path; + } + + return $return; + } + /** * Get the fully-qualified production URI for a static resource path.