mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
fix(audit): record API key internal id as audit actor
Requests authenticated with a standard API key produced audit log entries with an empty actor id and internal id. The key role builds a synthetic user with no id, and that user was used as the audit actor, so the actor identity was lost. Enrich the audit actor for standard API keys with the key document's id and sequence so audit entries correctly attribute the acting key.
This commit is contained in:
1 parent
cb6570124b
commit
ac44835f6c
1 file changed
+7
@@ -225,6 +225,13 @@ Http::init()
|
||||
API_KEY_ACCOUNT => ACTOR_TYPE_KEY_ACCOUNT,
|
||||
default => ACTOR_TYPE_KEY_ORGANIZATION,
|
||||
});
|
||||
|
||||
if ($apiKey->getType() === API_KEY_STANDARD) {
|
||||
$userClone
|
||||
->setAttribute('$id', $dbKey->getId())
|
||||
->setAttribute('$sequence', $dbKey->getSequence());
|
||||
}
|
||||
|
||||
$auditContext->user = $userClone;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user