1
0
Fork 0
mirror of synced 2024-07-08 16:06:02 +12:00

Backwards compatible approach

This commit is contained in:
Matej Bačo 2024-05-14 12:33:49 +00:00
parent 4d249c5d36
commit 37176e7865
3 changed files with 9 additions and 2 deletions

View file

@ -1148,7 +1148,7 @@ App::post('/v1/projects/:projectId/keys')
'expire' => $expire, 'expire' => $expire,
'sdks' => [], 'sdks' => [],
'accessedAt' => null, 'accessedAt' => null,
'secret' => API_KEY_STANDARD . '_' . \bin2hex(\random_bytes(128)), 'secret' => \bin2hex(\random_bytes(128)),
]); ]);
$key = $dbForConsole->createDocument('keys', $key); $key = $dbForConsole->createDocument('keys', $key);

View file

@ -242,7 +242,7 @@ App::init()
// Regular key // Regular key
// Check if given key match project API keys // Check if given key match project API keys
$key = $project->find('secret', $apiKey, 'keys'); $key = $project->find('secret', $authKey, 'keys');
if ($key) { if ($key) {
$user = new Document([ $user = new Document([
'$id' => '', '$id' => '',

View file

@ -4,6 +4,7 @@ namespace Appwrite\Utopia\Response\Model;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response\Model;
use Utopia\Database\Document;
class Key extends Model class Key extends Model
{ {
@ -93,4 +94,10 @@ class Key extends Model
{ {
return Response::MODEL_KEY; return Response::MODEL_KEY;
} }
public function filter(Document $document): Document
{
$document->setAttribute('secret', API_KEY_STANDARD . '_' . $document->getAttribute('secret', ''));
return $document;
}
} }