feat(audit): локальный журнал и push в auth-portal
Таблица audit_log, recordAudit на CRUD, GET /api/v1/audit и dual-write source_app=cfdm. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
30447d8380
commit
859ad23006
22 files changed
+1561
-106
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { request } from "undici";
|
||||
import type { IngestAuditEvent } from "@cfdm/shared";
|
||||
|
||||
export async function pushAuditEvents(
|
||||
portalUrl: string,
|
||||
secret: string,
|
||||
events: IngestAuditEvent[],
|
||||
): Promise<void> {
|
||||
const base = portalUrl.replace(/\/$/, "");
|
||||
const res = await request(`${base}/api/v1/ingest/audit`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
authorization: `Bearer ${secret}`,
|
||||
},
|
||||
body: JSON.stringify({ events }),
|
||||
});
|
||||
|
||||
if (res.statusCode >= 400) {
|
||||
const body = await res.body.text();
|
||||
throw new Error(`portal audit ingest ${res.statusCode}: ${body}`);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user