feat(api-keys): add platform-scoped API keys for control-plane automation

Introduce platform API keys with capability-based access to tenant management,
system settings, runtime queues, and audit logs, plus admin UI for key lifecycle
and system audit log viewing.
This commit is contained in:
wizardchen
2026-07-21 15:05:57 +08:00
committed by lyingbug
parent c695125dce
commit 23db592c4a
42 changed files with 2967 additions and 1083 deletions
+8 -3
View File
@@ -148,9 +148,14 @@ func RequireSystemAdmin(cfg *config.Config) gin.HandlerFunc {
warnOnNilConfig(cfg)
return func(c *gin.Context) {
ctx := c.Request.Context()
// API-key principals must never reach system-admin routes, even if a
// future route registration mistakenly declares an apiKey* policy.
if _, ok := types.TenantAPIKeyScopeFromContext(ctx); ok {
// The API-key gate runs before this guard and default-denies undeclared
// routes. Only platform keys that passed an explicit platform capability
// policy may reuse the system-admin handlers below.
if scope, ok := types.TenantAPIKeyScopeFromContext(ctx); ok {
if scope.IsPlatform() {
c.Next()
return
}
logger.Warnf(ctx,
"[rbac] system admin required: API-key principal denied path=%s",
c.Request.URL.Path)