Audit log: every change through the admin API and the administration pages, with ctl audit
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
bcd2413535
commit
f8fcecd640
18 files changed
+681
-7
No files matched your search
+13
-1
@@ -31,6 +31,7 @@ import (
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
llmgwv1 "gitea.mynodes.xyz/ilker/llmgw/api/gen/llmgw/v1"
|
||||
"gitea.mynodes.xyz/ilker/llmgw/internal/audit"
|
||||
"gitea.mynodes.xyz/ilker/llmgw/internal/config"
|
||||
"gitea.mynodes.xyz/ilker/llmgw/internal/control"
|
||||
"gitea.mynodes.xyz/ilker/llmgw/internal/control/adminapi"
|
||||
@@ -269,6 +270,7 @@ func newServerCmd() *cobra.Command {
|
||||
if st := rt.Store(); st != nil {
|
||||
// Removing a node revokes its certificate.
|
||||
api.SetRevoker(st.RevokeNode)
|
||||
api.SetAudit(st)
|
||||
}
|
||||
// Catalog changes need somewhere to persist, so this is wired
|
||||
// only when there is a store. Without one, the endpoints say so
|
||||
@@ -404,7 +406,7 @@ func newServerCmd() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
adminSrv := withLimits(&http.Server{
|
||||
Handler: router.AdminGuard(router.AdminAuth(adminToken, cfg.DebugPprof, adminMux)),
|
||||
Handler: router.AdminGuard(router.AdminAuth(adminToken, cfg.DebugPprof, auditAPI(rt, adminMux, log))),
|
||||
ReadTimeout: time.Minute,
|
||||
})
|
||||
|
||||
@@ -660,6 +662,16 @@ func startControlPlane(ctx context.Context, cfg config.Server, cat *catalog.Live
|
||||
return ctl, svc, nil
|
||||
}
|
||||
|
||||
// auditAPI records every change made through the admin API, when there is a
|
||||
// store to record it in.
|
||||
func auditAPI(rt *router.Router, next http.Handler, log *slog.Logger) http.Handler {
|
||||
st := rt.Store()
|
||||
if st == nil {
|
||||
return next
|
||||
}
|
||||
return audit.API(st, adminapi.Actor, log, next)
|
||||
}
|
||||
|
||||
// metricsAddr renders the metrics listener for the startup line, saying so
|
||||
// plainly when there is none rather than printing an empty string.
|
||||
func metricsAddr(ln net.Listener) string {
|
||||
|
||||
Reference in new issue
Block a user