diff options
| author | Chia <Chia@93.nz> | 2026-08-05 09:26:05 +1200 |
|---|---|---|
| committer | Chia <Chia@93.nz> | 2026-08-05 09:26:05 +1200 |
| commit | 86b1f42e3c5601ff10621a9779cf0076590797a1 (patch) | |
| tree | ccf584f0404dece2e4dae2eee847b665f57c0737 /internal/controlplane/audit.go | |
| parent | 1a3d7f9a8a181df48f0e911cbe17a3fad3ab9ac9 (diff) | |
add sth.
Diffstat (limited to '')
| -rw-r--r-- | internal/controlplane/audit.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/controlplane/audit.go b/internal/controlplane/audit.go index 93a4f58..8cb4ffe 100644 --- a/internal/controlplane/audit.go +++ b/internal/controlplane/audit.go @@ -8,13 +8,17 @@ import ( func (s *Store) WriteAudit(ctx context.Context, input AuditInput) error { actorType := "console_user" + actorRole := input.Actor.Role if input.Actor.Bootstrap { actorType = "bootstrap" + } else if input.Actor.ID == "" { + actorType = "anonymous" + actorRole = "anonymous" } _, err := s.db.Exec(ctx, `INSERT INTO audit_logs (actor_id, actor_type, actor_role, tenant_id, request_id, method, path, action, status_code, remote_ip, user_agent) VALUES (NULLIF($1,'')::uuid,$2,$3,NULLIF($4,'')::uuid,$5,$6,$7,$8,$9,NULLIF($10,'')::inet,$11)`, - input.Actor.ID, actorType, input.Actor.Role, input.Actor.TenantID, input.RequestID, input.Method, + input.Actor.ID, actorType, actorRole, input.Actor.TenantID, input.RequestID, input.Method, input.Path, input.Action, input.StatusCode, input.RemoteIP, input.UserAgent) if err != nil { return fmt.Errorf("write audit log: %w", err) |
