Watch
1
0
Fork
You've already forked RedFlag
0

security: latch /admin group behind RequireAdmin (SEC-026)

The /admin group rode on webAuthMW + audit only; just the securitySettings
sibling checked the role. Inert today (login mints role=admin), live the day
RBAC lands — one group-level gate beats per-route annotations to forget.
This commit is contained in:
Fimeg 2026-06-15 09:07:19 -04:00
commit cc19854941

View file

@ -887,6 +887,12 @@ func main() {
// Admin/Registration Token routes (for agent enrollment management)
auditMW := middleware.NewAuditMiddleware(db.DB)
admin := dashboard.Group("/admin")
// Trust boundary latch (ETHOS 11.4): the /admin group requires the admin
// role at the group level, not per-route. Inert today (login mints role
// "admin" only, auth.go), but the day role issuance diversifies the gate
// is already structurally correct — a non-admin can't reach any /admin
// handler, and there's no per-route annotation to forget.
admin.Use(middleware.RequireAdmin())
admin.Use(auditMW.Audit())
{
admin.POST("/registration-tokens", rateLimiter.RateLimit("admin_token_gen", middleware.KeyByUserID), registrationTokenHandler.GenerateRegistrationToken)