@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Aprhont - Adding cookie-prefix, as config option, and into cookie methods

Summary: Cookie-prefix should fix phabricator instances where x.com and x.y.com have conflicting cookie names

Test Plan: Pushed branch to dev.phab.example.com, logged into phab.example.com and into dev.phab.example.com.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7979

authored by

Alex Arwine and committed by
epriestley
e6a6c265 c40420eb

+29
+16
src/aphront/AphrontRequest.php
··· 273 273 return $this->validateCSRF(); 274 274 } 275 275 276 + final public function setCookiePrefix($prefix) { 277 + $this->cookiePrefix = $prefix; 278 + return $this; 279 + } 280 + 281 + final private function getPrefixedCookieName($name) { 282 + if (strlen($this->cookiePrefix)) { 283 + return $this->cookiePrefix.'_'.$name; 284 + } else { 285 + return $name; 286 + } 287 + } 288 + 276 289 final public function getCookie($name, $default = null) { 290 + $name = $this->getPrefixedCookieName($name); 277 291 return idx($_COOKIE, $name, $default); 278 292 } 279 293 280 294 final public function clearCookie($name) { 295 + $name = $this->getPrefixedCookieName($name); 281 296 $this->setCookie($name, '', time() - (60 * 60 * 24 * 30)); 282 297 unset($_COOKIE[$name]); 283 298 } ··· 342 357 $expire = time() + (60 * 60 * 24 * 365 * 5); 343 358 } 344 359 360 + $name = $this->getPrefixedCookieName($name); 345 361 346 362 if (php_sapi_name() == 'cli') { 347 363 // Do nothing, to avoid triggering "Cannot modify header information"
+3
src/aphront/configuration/AphrontDefaultApplicationConfiguration.php
··· 107 107 108 108 $data += $parser->parseQueryString(idx($_SERVER, 'QUERY_STRING', '')); 109 109 110 + $cookie_prefix = PhabricatorEnv::getEnvConfig('phabricator.cookie-prefix'); 111 + 110 112 $request = new AphrontRequest($this->getHost(), $this->getPath()); 111 113 $request->setRequestData($data); 112 114 $request->setApplicationConfiguration($this); 115 + $request->setCookiePrefix($cookie_prefix); 113 116 114 117 return $request; 115 118 }
+10
src/applications/config/option/PhabricatorCoreConfigOptions.php
··· 76 76 ->addExample('America/Chicago', pht('US Central (CDT)')) 77 77 ->addExample('America/Boise', pht('US Mountain (MDT)')) 78 78 ->addExample('America/Los_Angeles', pht('US West (PDT)')), 79 + $this->newOption('phabricator.cookie-prefix', 'string', null) 80 + ->setSummary( 81 + pht("Set a string Phabricator should use to prefix ". 82 + "cookie names")) 83 + ->setDescription( 84 + pht( 85 + "Cookies set for x.com are also sent for y.x.com. Assuming ". 86 + "Phabricator instances are running on both domains, this will ". 87 + "create a collision preventing you from logging in.")) 88 + ->addExample('dev', pht('Prefix cookie with "dev"')), 79 89 $this->newOption('phabricator.show-beta-applications', 'bool', false) 80 90 ->setBoolOptions( 81 91 array(