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:
@@ -21,6 +21,10 @@ var errTenantAPIKeyScopeForbidden = stderrors.New("workspace API key scope forbi
|
||||
// default (fail-closed), which removes the old "remember to add APIKeyDeny"
|
||||
// footgun.
|
||||
type APIKeyRoutePolicy struct {
|
||||
// PlatformOnly rejects workspace-bound keys even when they are full-access.
|
||||
// It is used for control-plane routes under /system/admin and cross-workspace
|
||||
// tenant lifecycle APIs.
|
||||
PlatformOnly bool
|
||||
// RequireFullAccess admits only full-access tenant API keys unless one of
|
||||
// the listed capabilities also matches. Routes with neither full-access
|
||||
// requirement nor capabilities are open to any valid API key.
|
||||
@@ -128,6 +132,12 @@ func (a *APIKeyRouteAuthorizer) authorize(scope types.TenantAPIKeyScope, method,
|
||||
if !ok {
|
||||
return errTenantAPIKeyScopeForbidden
|
||||
}
|
||||
if policy.PlatformOnly && !scope.IsPlatform() {
|
||||
return errTenantAPIKeyScopeForbidden
|
||||
}
|
||||
if policy.PlatformOnly && len(policy.Capabilities) == 0 {
|
||||
return errTenantAPIKeyScopeForbidden
|
||||
}
|
||||
if scope.FullAccess {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user