feat: add new attributes for API Keys
This commit is contained in:
parent
78d02f50af
commit
c96f1e76e2
|
@ -972,6 +972,28 @@ $collections = [
|
|||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => 'accessedAt',
|
||||
'type' => Database::VAR_INTEGER,
|
||||
'format' => '',
|
||||
'size' => 0,
|
||||
'signed' => false,
|
||||
'required' => false,
|
||||
'default' => 0,
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => 'sdks',
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => Database::LENGTH_KEY,
|
||||
'signed' => true,
|
||||
'required' => true,
|
||||
'default' => null,
|
||||
'array' => true,
|
||||
'filters' => [],
|
||||
],
|
||||
],
|
||||
'indexes' => [
|
||||
[
|
||||
|
@ -981,6 +1003,13 @@ $collections = [
|
|||
'lengths' => [Database::LENGTH_KEY],
|
||||
'orders' => [Database::ORDER_ASC],
|
||||
],
|
||||
[
|
||||
'$id' => '_key_accessedAt',
|
||||
'type' => Database::INDEX_KEY,
|
||||
'attributes' => ['accessedAt'],
|
||||
'lengths' => [],
|
||||
'orders' => [],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
|
|
|
@ -841,6 +841,8 @@ App::post('/v1/projects/:projectId/keys')
|
|||
'name' => $name,
|
||||
'scopes' => $scopes,
|
||||
'expire' => $expire,
|
||||
'sdks' => [],
|
||||
'accessedAt' => 0,
|
||||
'secret' => \bin2hex(\random_bytes(128)),
|
||||
]);
|
||||
|
||||
|
|
|
@ -281,6 +281,7 @@ App::init()
|
|||
* Mock user to app and grant API key scopes in addition to default app scopes
|
||||
*/
|
||||
if ($key && $user->isEmpty()) {
|
||||
var_dump($key);
|
||||
$user = new Document([
|
||||
'$id' => '',
|
||||
'status' => true,
|
||||
|
|
|
@ -58,6 +58,18 @@ class Key extends Model
|
|||
'default' => '',
|
||||
'example' => '919c2d18fb5d4...a2ae413da83346ad2',
|
||||
])
|
||||
->addRule('accessedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Most recent access date in Unix timestamp.',
|
||||
'default' => null,
|
||||
'example' => '1653990687',
|
||||
])
|
||||
->addRule('sdks', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'List of SDK user agents that used this key.',
|
||||
'default' => null,
|
||||
'example' => 'appwrite:flutter',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue