chore(canary-phase12): admin endpoints + OperatorBearer complete
Phase 12 deliverables (audited PASS):
- internal/middleware/operator_bearer.go — 404-on-miss (not 401),
subtle.ConstantTimeCompare on token, defense-in-depth empty-config
rejection; per spec §11.5.
- internal/admin/{handler,dto}.go — three endpoints from spec §8.1:
GET /api/admin/stats (tokens_count + events_count + by_type +
by_alert_channel), GET /api/admin/tokens (offset paging, 50/100
default/cap), POST /api/admin/tokens/{id}/disable (204 / 404).
Replaces the unused template stats package per spec §5 line 282
("KEEP, repurpose for operator stats; gate via OperatorBearer").
- internal/{token,event}/repository.go — CountByType + CountByAlertChannel
+ event.CountAll feed the stats endpoint via repo grouping queries.
- cmd/canary/main.go — mountAdminRoutes helper skips mount entirely
when OPERATOR_TOKEN is unset (production safety; runtime warn log).
- config.OperatorConfig + OPERATOR_TOKEN env mapping.
- Unit + integration test coverage at admin/middleware boundaries
including the 404-no-WWW-Authenticate regression assertion.
Audited: superpowers:code-reviewer + general-purpose spec adherence — PASS.
This commit is contained in:
parent
3cf198657b
commit
d870e85f23