feat(api): record an audit log and show it to organizations, users and admins
Every state-changing API route is mapped to an action; a test fails for unmapped routes. Successful changes are recorded with actor, API token, target, IP, user agent and request ID; failed sign-ins too. Names are taken from the response, never secrets. Organizations read their log with audit.read under Settings, users their account activity on the security page, admins the platform log. Entries expire after UPTIME_RETENTION_AUDIT. Closes #65 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
789ef077eb
commit
358b191976
18 files changed
+1184
-76
No files matched your search
@@ -82,7 +82,7 @@ func (s *Server) Mount(r gin.IRouter) {
|
||||
// the session and CSRF middleware.
|
||||
s.mountAgentAPI(r)
|
||||
|
||||
g := r.Group("/", s.sessions.Load(), s.localize(), auth.CSRF())
|
||||
g := r.Group("/", s.sessions.Load(), s.localize(), auth.CSRF(), s.audit())
|
||||
|
||||
v1 := g.Group("/api/v1")
|
||||
v1.POST("/locale", s.setLocale)
|
||||
@@ -100,6 +100,7 @@ func (s *Server) Mount(r gin.IRouter) {
|
||||
me.POST("/totp/enable", s.totpEnable)
|
||||
me.POST("/totp/disable", s.totpDisable)
|
||||
me.POST("/totp/recovery-codes", s.regenerateRecoveryCodes)
|
||||
me.GET("/audit", s.listMyAudit)
|
||||
|
||||
v1.POST("/invitations/:token/accept", auth.Require(), s.acceptInvitation)
|
||||
v1.POST("/invitations/:token/signup", s.inviteSignup)
|
||||
@@ -126,6 +127,7 @@ func (s *Server) Mount(r gin.IRouter) {
|
||||
org.DELETE("/agents/:id", sessionOnly(), can(authz.OrgManage), s.deleteOrgAgent)
|
||||
|
||||
admin := v1.Group("/admin", s.requireAdmin())
|
||||
admin.GET("/audit", s.listPlatformAudit)
|
||||
admin.GET("/regions", s.adminListRegions)
|
||||
admin.POST("/regions", s.adminCreateRegion)
|
||||
admin.DELETE("/regions/:id", s.adminDeleteRegion)
|
||||
@@ -144,6 +146,7 @@ func (s *Server) Mount(r gin.IRouter) {
|
||||
page.GET("/export", canPage(authz.StatusPagesRead), s.exportStatusPage)
|
||||
|
||||
org.GET("/incidents", can(authz.IncidentsRead), s.listIncidents)
|
||||
org.GET("/audit", can(authz.AuditRead), s.listOrgAudit)
|
||||
|
||||
org.GET("/channels", can(authz.NotificationsRead), s.listChannels)
|
||||
org.POST("/channels", can(authz.NotificationsWrite), s.createChannel)
|
||||
|
||||
Reference in new issue
Block a user