Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/env/PhabricatorEnv.php
| Show First 20 Lines • Show All 522 Lines • ▼ Show 20 Lines | public static function isValidRemoteWebResource($uri) { | ||||
| $allowed = self::getEnvConfig('uri.allowed-protocols'); | $allowed = self::getEnvConfig('uri.allowed-protocols'); | ||||
| if (empty($allowed[$proto])) { | if (empty($allowed[$proto])) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| public static function isClusterRemoteAddress() { | |||||
| $address = idx($_SERVER, 'REMOTE_ADDR'); | |||||
| if (!$address) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Unable to test remote address against cluster whitelist: '. | |||||
| 'REMOTE_ADDR is not defined.')); | |||||
| } | |||||
| return self::isClusterAddress($address); | |||||
| } | |||||
| public static function isClusterAddress($address) { | |||||
| $cluster_addresses = PhabricatorEnv::getEnvConfig('cluster.addresses'); | |||||
| if (!$cluster_addresses) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Phabricator is not configured to serve cluster requests. '. | |||||
| 'Set `cluster.addresses` in the configuration to whitelist '. | |||||
| 'cluster hosts before sending requests that use a cluster '. | |||||
| 'authentication mechanism.')); | |||||
| } | |||||
| return PhutilCIDRList::newList($cluster_addresses) | |||||
| ->containsAddress($address); | |||||
| } | |||||
| /* -( Internals )---------------------------------------------------------- */ | /* -( Internals )---------------------------------------------------------- */ | ||||
| /** | /** | ||||
| * @task internal | * @task internal | ||||
| */ | */ | ||||
| public static function envConfigExists($key) { | public static function envConfigExists($key) { | ||||
| ▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines | |||||