From 44537a1c112fd2c891ee99875264846eca7a9e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Untersch=C3=BCtz?= Date: Sun, 22 Nov 2026 10:17:39 +0100 Subject: [PATCH] fix(api): keep the email of successful sign-ins out of the audit details The account is already the actor; the address is only useful for failed attempts on unknown accounts. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3 --- internal/api/audit.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/api/audit.go b/internal/api/audit.go index 887f0fb..c59fe9d 100644 --- a/internal/api/audit.go +++ b/internal/api/audit.go @@ -76,6 +76,8 @@ var auditActions = map[string]string{ "POST /api/v1/org/tokens": "token.create", "DELETE /api/v1/org/tokens/:id": "token.delete", + "PUT /api/v1/admin/legal/:kind": "platform.legal_update", + "PUT /api/v1/org/legal/:kind": "org.legal_update", "POST /api/v1/admin/regions": "platform.region_create", "DELETE /api/v1/admin/regions/:id": "platform.region_delete", "POST /api/v1/admin/agents": "platform.agent_create", @@ -131,7 +133,7 @@ func (w *captureWriter) Write(b []byte) (int, error) { // Response fields worth keeping; anything else may be a secret, such as a // freshly created token. -var auditFields = []string{"name", "key", "slug", "email", "type", "target", "domain"} +var auditFields = []string{"name", "key", "slug", "email", "type", "target", "domain", "kind"} // audit records state-changing requests after they ran. func (s *Server) audit() gin.HandlerFunc { @@ -170,6 +172,10 @@ func (s *Server) audit() gin.HandlerFunc { } } } + if status < 400 && strings.HasPrefix(action, "auth.") { + // The address only identifies attempts on unknown accounts. + delete(details, "email") + } for _, param := range []string{"id", "user"} { if id, err := uuid.Parse(c.Param(param)); err == nil { e.TargetID = &id