Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14348012
D15481.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D15481.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2352,6 +2352,7 @@
'PhabricatorFeedStoryPublisher' => 'applications/feed/PhabricatorFeedStoryPublisher.php',
'PhabricatorFeedStoryReference' => 'applications/feed/storage/PhabricatorFeedStoryReference.php',
'PhabricatorFile' => 'applications/files/storage/PhabricatorFile.php',
+ 'PhabricatorFileAccessTemporaryTokenType' => 'applications/files/temporarytoken/PhabricatorFileAccessTemporaryTokenType.php',
'PhabricatorFileBundleLoader' => 'applications/files/query/PhabricatorFileBundleLoader.php',
'PhabricatorFileChunk' => 'applications/files/storage/PhabricatorFileChunk.php',
'PhabricatorFileChunkIterator' => 'applications/files/engine/PhabricatorFileChunkIterator.php',
@@ -6770,6 +6771,7 @@
'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface',
),
+ 'PhabricatorFileAccessTemporaryTokenType' => 'PhabricatorAuthTemporaryTokenType',
'PhabricatorFileBundleLoader' => 'Phobject',
'PhabricatorFileChunk' => array(
'PhabricatorFileDAO',
diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php
--- a/src/applications/files/storage/PhabricatorFile.php
+++ b/src/applications/files/storage/PhabricatorFile.php
@@ -26,7 +26,6 @@
PhabricatorPolicyInterface,
PhabricatorDestructibleInterface {
- const ONETIME_TEMPORARY_TOKEN_TYPE = 'file:onetime';
const STORAGE_FORMAT_RAW = 'raw';
const METADATA_IMAGE_WIDTH = 'width';
@@ -1119,12 +1118,13 @@
protected function generateOneTimeToken() {
$key = Filesystem::readRandomCharacters(16);
+ $token_type = PhabricatorFileAccessTemporaryTokenType::TOKENTYPE;
// Save the new secret.
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$token = id(new PhabricatorAuthTemporaryToken())
->setTokenResource($this->getPHID())
- ->setTokenType(self::ONETIME_TEMPORARY_TOKEN_TYPE)
+ ->setTokenType($token_type)
->setTokenExpires(time() + phutil_units('1 hour in seconds'))
->setTokenCode(PhabricatorHash::digest($key))
->save();
@@ -1134,10 +1134,12 @@
}
public function validateOneTimeToken($token_code) {
+ $token_type = PhabricatorFileAccessTemporaryTokenType::TOKENTYPE;
+
$token = id(new PhabricatorAuthTemporaryTokenQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withTokenResources(array($this->getPHID()))
- ->withTokenTypes(array(self::ONETIME_TEMPORARY_TOKEN_TYPE))
+ ->withTokenTypes(array($token_type))
->withExpired(false)
->withTokenCodes(array(PhabricatorHash::digest($token_code)))
->executeOne();
diff --git a/src/applications/files/temporarytoken/PhabricatorFileAccessTemporaryTokenType.php b/src/applications/files/temporarytoken/PhabricatorFileAccessTemporaryTokenType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/files/temporarytoken/PhabricatorFileAccessTemporaryTokenType.php
@@ -0,0 +1,17 @@
+<?php
+
+final class PhabricatorFileAccessTemporaryTokenType
+ extends PhabricatorAuthTemporaryTokenType {
+
+ const TOKENTYPE = 'file:onetime';
+
+ public function getTokenTypeDisplayName() {
+ return pht('File Access');
+ }
+
+ public function getTokenReadableTypeName(
+ PhabricatorAuthTemporaryToken $token) {
+ return pht('File Access Token');
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 4:53 AM (17 h, 57 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6906442
Default Alt Text
D15481.diff (3 KB)
Attached To
Mode
D15481: Convert one-time file access tokens to modular token types
Attached
Detach File
Event Timeline
Log In to Comment