@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.

Add a session engine extension point

Summary: Ref T7673. This is really just so I can force admin.phacility.com logout when you log out of an instance, but there are a few other things we could move here eventually, like the WILLREGISTERUSER event.

Test Plan: Logged out of an instance, got logged out of parent (see next change).

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7673

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

+127 -44
+4
src/__phutil_library_map__.php
··· 1848 1848 'PhabricatorAuthSSHPublicKey' => 'applications/auth/sshkey/PhabricatorAuthSSHPublicKey.php', 1849 1849 'PhabricatorAuthSession' => 'applications/auth/storage/PhabricatorAuthSession.php', 1850 1850 'PhabricatorAuthSessionEngine' => 'applications/auth/engine/PhabricatorAuthSessionEngine.php', 1851 + 'PhabricatorAuthSessionEngineExtension' => 'applications/auth/engine/PhabricatorAuthSessionEngineExtension.php', 1852 + 'PhabricatorAuthSessionEngineExtensionModule' => 'applications/auth/engine/PhabricatorAuthSessionEngineExtensionModule.php', 1851 1853 'PhabricatorAuthSessionGarbageCollector' => 'applications/auth/garbagecollector/PhabricatorAuthSessionGarbageCollector.php', 1852 1854 'PhabricatorAuthSessionQuery' => 'applications/auth/query/PhabricatorAuthSessionQuery.php', 1853 1855 'PhabricatorAuthSetupCheck' => 'applications/config/check/PhabricatorAuthSetupCheck.php', ··· 6206 6208 'PhabricatorPolicyInterface', 6207 6209 ), 6208 6210 'PhabricatorAuthSessionEngine' => 'Phobject', 6211 + 'PhabricatorAuthSessionEngineExtension' => 'Phobject', 6212 + 'PhabricatorAuthSessionEngineExtensionModule' => 'PhabricatorConfigModule', 6209 6213 'PhabricatorAuthSessionGarbageCollector' => 'PhabricatorGarbageCollector', 6210 6214 'PhabricatorAuthSessionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 6211 6215 'PhabricatorAuthSetupCheck' => 'PhabricatorSetupCheck',
+3 -8
src/applications/auth/controller/PhabricatorLogoutController.php
··· 29 29 $viewer = $this->getViewer(); 30 30 31 31 if ($request->isFormPost()) { 32 - 33 - $log = PhabricatorUserLog::initializeNewLog( 34 - $viewer, 35 - $viewer->getPHID(), 36 - PhabricatorUserLog::ACTION_LOGOUT); 37 - $log->save(); 38 - 39 32 // Destroy the user's session in the database so logout works even if 40 33 // their cookies have some issues. We'll detect cookie issues when they 41 34 // try to login again and tell them to clear any junk. ··· 45 38 ->setViewer($viewer) 46 39 ->withSessionKeys(array($phsid)) 47 40 ->executeOne(); 41 + 48 42 if ($session) { 49 - $session->delete(); 43 + $engine = new PhabricatorAuthSessionEngine(); 44 + $engine->logoutSession($viewer, $session); 50 45 } 51 46 } 52 47 $request->clearCookie(PhabricatorCookies::COOKIE_SESSION);
+18
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
··· 297 297 } 298 298 } 299 299 300 + public function logoutSession( 301 + PhabricatorUser $user, 302 + PhabricatorAuthSession $session) { 303 + 304 + $log = PhabricatorUserLog::initializeNewLog( 305 + $user, 306 + $user->getPHID(), 307 + PhabricatorUserLog::ACTION_LOGOUT); 308 + $log->save(); 309 + 310 + $extensions = PhabricatorAuthSessionEngineExtension::getAllExtensions(); 311 + foreach ($extensions as $extension) { 312 + $extension->didLogout($user, array($session)); 313 + } 314 + 315 + $session->delete(); 316 + } 317 + 300 318 301 319 /* -( High Security )------------------------------------------------------ */ 302 320
+23
src/applications/auth/engine/PhabricatorAuthSessionEngineExtension.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorAuthSessionEngineExtension 4 + extends Phobject { 5 + 6 + final public function getExtensionKey() { 7 + return $this->getPhobjectClassConstant('EXTENSIONKEY'); 8 + } 9 + 10 + final public static function getAllExtensions() { 11 + return id(new PhutilClassMapQuery()) 12 + ->setAncestorClass(__CLASS__) 13 + ->setUniqueMethod('getExtensionKey') 14 + ->execute(); 15 + } 16 + 17 + abstract public function getExtensionName(); 18 + 19 + public function didLogout(PhabricatorUser $user, array $sessions) { 20 + return; 21 + } 22 + 23 + }
+49
src/applications/auth/engine/PhabricatorAuthSessionEngineExtensionModule.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthSessionEngineExtensionModule 4 + extends PhabricatorConfigModule { 5 + 6 + public function getModuleKey() { 7 + return 'sessionengine'; 8 + } 9 + 10 + public function getModuleName() { 11 + return pht('Engine: Session'); 12 + } 13 + 14 + public function renderModuleStatus(AphrontRequest $request) { 15 + $viewer = $request->getViewer(); 16 + 17 + $extensions = PhabricatorAuthSessionEngineExtension::getAllExtensions(); 18 + 19 + $rows = array(); 20 + foreach ($extensions as $extension) { 21 + $rows[] = array( 22 + get_class($extension), 23 + $extension->getExtensionKey(), 24 + $extension->getExtensionName(), 25 + ); 26 + } 27 + 28 + $table = id(new AphrontTableView($rows)) 29 + ->setNoDataString( 30 + pht('There are no registered session engine extensions.')) 31 + ->setHeaders( 32 + array( 33 + pht('Class'), 34 + pht('Key'), 35 + pht('Name'), 36 + )) 37 + ->setColumnClasses( 38 + array( 39 + null, 40 + null, 41 + 'wide pri', 42 + )); 43 + 44 + return id(new PHUIObjectBoxView()) 45 + ->setHeaderText(pht('SessionEngine Extensions')) 46 + ->setTable($table); 47 + } 48 + 49 + }
+5
src/applications/auth/provider/PhabricatorPhabricatorAuthProvider.php
··· 201 201 return true; 202 202 } 203 203 204 + public function getPhabricatorURI() { 205 + $config = $this->getProviderConfig(); 206 + return $config->getProperty(self::PROPERTY_PHABRICATOR_URI); 207 + } 208 + 204 209 }
+22 -31
src/applications/auth/query/PhabricatorExternalAccountQuery.php
··· 62 62 return $this; 63 63 } 64 64 65 + public function newResultObject() { 66 + return new PhabricatorExternalAccount(); 67 + } 68 + 65 69 protected function loadPage() { 66 - $table = new PhabricatorExternalAccount(); 67 - $conn_r = $table->establishConnection('r'); 68 - 69 - $data = queryfx_all( 70 - $conn_r, 71 - 'SELECT * FROM %T %Q %Q %Q', 72 - $table->getTableName(), 73 - $this->buildWhereClause($conn_r), 74 - $this->buildOrderClause($conn_r), 75 - $this->buildLimitClause($conn_r)); 76 - 77 - return $table->loadAllFromArray($data); 70 + return $this->loadStandardPage($this->newResultObject()); 78 71 } 79 72 80 73 protected function willFilterPage(array $accounts) { ··· 116 109 return $accounts; 117 110 } 118 111 119 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 120 - $where = array(); 121 - 122 - $where[] = $this->buildPagingClause($conn_r); 112 + protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 113 + $where = parent::buildWhereClauseParts($conn); 123 114 124 - if ($this->ids) { 115 + if ($this->ids !== null) { 125 116 $where[] = qsprintf( 126 - $conn_r, 117 + $conn, 127 118 'id IN (%Ld)', 128 119 $this->ids); 129 120 } 130 121 131 - if ($this->phids) { 122 + if ($this->phids !== null) { 132 123 $where[] = qsprintf( 133 - $conn_r, 124 + $conn, 134 125 'phid IN (%Ls)', 135 126 $this->phids); 136 127 } 137 128 138 - if ($this->accountTypes) { 129 + if ($this->accountTypes !== null) { 139 130 $where[] = qsprintf( 140 - $conn_r, 131 + $conn, 141 132 'accountType IN (%Ls)', 142 133 $this->accountTypes); 143 134 } 144 135 145 - if ($this->accountDomains) { 136 + if ($this->accountDomains !== null) { 146 137 $where[] = qsprintf( 147 - $conn_r, 138 + $conn, 148 139 'accountDomain IN (%Ls)', 149 140 $this->accountDomains); 150 141 } 151 142 152 - if ($this->accountIDs) { 143 + if ($this->accountIDs !== null) { 153 144 $where[] = qsprintf( 154 - $conn_r, 145 + $conn, 155 146 'accountID IN (%Ls)', 156 147 $this->accountIDs); 157 148 } 158 149 159 - if ($this->userPHIDs) { 150 + if ($this->userPHIDs !== null) { 160 151 $where[] = qsprintf( 161 - $conn_r, 152 + $conn, 162 153 'userPHID IN (%Ls)', 163 154 $this->userPHIDs); 164 155 } 165 156 166 - if ($this->accountSecrets) { 157 + if ($this->accountSecrets !== null) { 167 158 $where[] = qsprintf( 168 - $conn_r, 159 + $conn, 169 160 'accountSecret IN (%Ls)', 170 161 $this->accountSecrets); 171 162 } 172 163 173 - return $this->formatWhereClause($where); 164 + return $where; 174 165 } 175 166 176 167 public function getQueryApplicationClass() {
+3 -5
src/applications/people/storage/PhabricatorExternalAccount.php
··· 54 54 'accountURI' => 'text255?', 55 55 ), 56 56 self::CONFIG_KEY_SCHEMA => array( 57 - 'key_phid' => null, 58 - 'phid' => array( 59 - 'columns' => array('phid'), 60 - 'unique' => true, 61 - ), 62 57 'account_details' => array( 63 58 'columns' => array('accountType', 'accountDomain', 'accountID'), 64 59 'unique' => true, 60 + ), 61 + 'key_user' => array( 62 + 'columns' => array('userPHID'), 65 63 ), 66 64 ), 67 65 ) + parent::getConfiguration();