Backwards compatible approach
This commit is contained in:
parent
4d249c5d36
commit
37176e7865
|
@ -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);
|
||||||
|
|
|
@ -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' => '',
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue