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

Convert one-time file access tokens to modular token types

Summary: Fixes T10603. This is the last of the ad-hoc temporary tokens.

Test Plan:
- Used a file token.
- Viewed type in {nav Config > Temporary Tokens}.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10603

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

+24 -3
+2
src/__phutil_library_map__.php
··· 2352 2352 'PhabricatorFeedStoryPublisher' => 'applications/feed/PhabricatorFeedStoryPublisher.php', 2353 2353 'PhabricatorFeedStoryReference' => 'applications/feed/storage/PhabricatorFeedStoryReference.php', 2354 2354 'PhabricatorFile' => 'applications/files/storage/PhabricatorFile.php', 2355 + 'PhabricatorFileAccessTemporaryTokenType' => 'applications/files/temporarytoken/PhabricatorFileAccessTemporaryTokenType.php', 2355 2356 'PhabricatorFileBundleLoader' => 'applications/files/query/PhabricatorFileBundleLoader.php', 2356 2357 'PhabricatorFileChunk' => 'applications/files/storage/PhabricatorFileChunk.php', 2357 2358 'PhabricatorFileChunkIterator' => 'applications/files/engine/PhabricatorFileChunkIterator.php', ··· 6770 6771 'PhabricatorPolicyInterface', 6771 6772 'PhabricatorDestructibleInterface', 6772 6773 ), 6774 + 'PhabricatorFileAccessTemporaryTokenType' => 'PhabricatorAuthTemporaryTokenType', 6773 6775 'PhabricatorFileBundleLoader' => 'Phobject', 6774 6776 'PhabricatorFileChunk' => array( 6775 6777 'PhabricatorFileDAO',
+5 -3
src/applications/files/storage/PhabricatorFile.php
··· 26 26 PhabricatorPolicyInterface, 27 27 PhabricatorDestructibleInterface { 28 28 29 - const ONETIME_TEMPORARY_TOKEN_TYPE = 'file:onetime'; 30 29 const STORAGE_FORMAT_RAW = 'raw'; 31 30 32 31 const METADATA_IMAGE_WIDTH = 'width'; ··· 1119 1118 1120 1119 protected function generateOneTimeToken() { 1121 1120 $key = Filesystem::readRandomCharacters(16); 1121 + $token_type = PhabricatorFileAccessTemporaryTokenType::TOKENTYPE; 1122 1122 1123 1123 // Save the new secret. 1124 1124 $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); 1125 1125 $token = id(new PhabricatorAuthTemporaryToken()) 1126 1126 ->setTokenResource($this->getPHID()) 1127 - ->setTokenType(self::ONETIME_TEMPORARY_TOKEN_TYPE) 1127 + ->setTokenType($token_type) 1128 1128 ->setTokenExpires(time() + phutil_units('1 hour in seconds')) 1129 1129 ->setTokenCode(PhabricatorHash::digest($key)) 1130 1130 ->save(); ··· 1134 1134 } 1135 1135 1136 1136 public function validateOneTimeToken($token_code) { 1137 + $token_type = PhabricatorFileAccessTemporaryTokenType::TOKENTYPE; 1138 + 1137 1139 $token = id(new PhabricatorAuthTemporaryTokenQuery()) 1138 1140 ->setViewer(PhabricatorUser::getOmnipotentUser()) 1139 1141 ->withTokenResources(array($this->getPHID())) 1140 - ->withTokenTypes(array(self::ONETIME_TEMPORARY_TOKEN_TYPE)) 1142 + ->withTokenTypes(array($token_type)) 1141 1143 ->withExpired(false) 1142 1144 ->withTokenCodes(array(PhabricatorHash::digest($token_code))) 1143 1145 ->executeOne();
+17
src/applications/files/temporarytoken/PhabricatorFileAccessTemporaryTokenType.php
··· 1 + <?php 2 + 3 + final class PhabricatorFileAccessTemporaryTokenType 4 + extends PhabricatorAuthTemporaryTokenType { 5 + 6 + const TOKENTYPE = 'file:onetime'; 7 + 8 + public function getTokenTypeDisplayName() { 9 + return pht('File Access'); 10 + } 11 + 12 + public function getTokenReadableTypeName( 13 + PhabricatorAuthTemporaryToken $token) { 14 + return pht('File Access Token'); 15 + } 16 + 17 + }