Files
ai/controllers/template_deploy.go
4d9d71fad6 refactor(authz): one super-admin rule — membership in the admin org (#76) (#82)
Per directive: "remove global admin, superadmin is just in 'admin' org in
IAM." Collapse the configurable global-admin abstraction to a single,
value-based rule matching IAM's user.IsGlobalAdmin (owner == conf.AdminOrg)
and the console isSuperAdminAccount gate (owner === 'admin').

util/permission.go:
- DELETE defaultGlobalAdminOrgs ({admin, built-in}), the globalAdminOrgs
  env/config knob, and globalAdminOrgSet().
- IsGlobalAdmin(isAdmin && owner∈set) → IsSuperAdmin(user) =
  user != nil && user.Owner == AdminOrg. AdminOrg = "admin" is the ONE
  definition. Membership alone is authoritative (no isAdmin flag, no
  "built-in" org) — a tenant-org admin (hanzo/z, maxpower/dave) is NEVER
  a super admin.

Ripple (values, not places — one coherent term):
- RequireGlobalAdmin → RequireSuperAdmin (controller self-guard, ~20 sites)
- globalAdminEndpoints/requiresGlobalAdmin → superAdminEndpoints/requiresSuperAdmin
- accountResponse JSON isGlobalAdmin → isSuperAdmin (deployed console
  v8.4.x reads isSuperAdmin-first + owner==admin fallback, so wire-safe)
- all prose "global admin" → "super admin"; kept the two comment refs to
  IAM's own user.IsGlobalAdmin method verbatim (they name a real method)

TDD: permission_superadmin_test (hanzo/z NOT super, admin/z IS super,
built-in retired, membership-without-isAdmin IS super) + RequireSuperAdmin
guard tests (org admin→403, super→pass, none→401) all green. Full build +
vet + gofumpt clean.


Co-authored-by: hanzo-dev <[email protected]>
2026-07-09 08:55:08 -07:00

40 lines
1.2 KiB
Go

// Copyright 2023-2025 Hanzo AI Inc. All Rights Reserved.
// Portions Copyright 2025 The OpenAgent Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package controllers
import (
"github.com/hanzoai/ai/object"
)
// GetK8sStatus
// @Title GetK8sStatus
// @Tag Deployment API
// @Description get kubernetes cluster status
// @Success 200 {object} object.K8sStatus The Response object
// @router /get-k8s-status [get]
func (c *ApiController) GetK8sStatus() {
if !c.RequireSuperAdmin() {
return
}
status, err := object.GetK8sStatus(c.GetAcceptLanguage())
if err != nil {
c.ResponseError(err.Error())
return
}
c.ResponseOk(status)
}