feat(audit,approvals,deliveries): wire audit producers, ITSM change requests, and fix Dockerfile.archie (#2153)
This commit is contained in:
26 files changed
+671
-35
No files matched your search
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/platform/httpapi"
|
||||
"github.com/samcharles93/archie-core/internal/platform/httpjson"
|
||||
"github.com/samcharles93/archie-core/modules/audit"
|
||||
"github.com/samcharles93/archie-core/modules/governance"
|
||||
)
|
||||
|
||||
@@ -36,6 +37,7 @@ type Module struct {
|
||||
bootstrap Bootstrap
|
||||
rotate func(hash string) error
|
||||
sources Sources
|
||||
audit audit.Recorder
|
||||
log *slog.Logger
|
||||
}
|
||||
|
||||
@@ -45,6 +47,9 @@ func New(b Bootstrap, rotate func(hash string) error, log *slog.Logger) *Module
|
||||
return &Module{bootstrap: b, rotate: rotate, log: log}
|
||||
}
|
||||
|
||||
// UseAudit configures the audit recorder notified on administrative actions.
|
||||
func (m *Module) UseAudit(r audit.Recorder) { m.audit = r }
|
||||
|
||||
// Register adds the system API.
|
||||
func (m *Module) Register(api huma.API) {
|
||||
tags := []string{"System"}
|
||||
@@ -88,6 +93,14 @@ func (m *Module) rotateAdminToken(ctx context.Context, _ *struct{}) (*httpapi.Re
|
||||
m.bootstrap.AdminPrefix, m.bootstrap.AdminSet = hash[:8], true
|
||||
m.mu.Unlock()
|
||||
m.log.InfoContext(ctx, "admin token rotated", "audit", true, "action", "admin.token.rotate")
|
||||
audit.Emit(ctx, m.audit, m.log, audit.Event{
|
||||
Category: "auth",
|
||||
Action: "admin.token.rotate",
|
||||
ActorID: governance.CallerID(ctx),
|
||||
ResourceKind: "instance",
|
||||
ResourceID: "admin_token",
|
||||
Outcome: "success",
|
||||
})
|
||||
return httpapi.OK(adminToken{Token: token}), nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user