diff options
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) |
