mirror of
https://github.com/hanzoai/ai.git
synced 2026-11-20 14:13:23 +00:00
util.IsSuperAdmin compared the resolved user's owner to "admin", a second predicate beside the one the host boundary decides, and the two disagreed. An admin-org application (no orgs, owner claim admin), an admin-org person's sk- key, and an org spelled "admin " (the parse trimmed orgs[0]) were each SuperAdmin here and refused by the boundary. The host now states the verdict: object.SetSuper, which hanzo-inc/cloud fills with principal.Super, the X-User-IsAdmin its boundary deletes from every request and re-mints from authz.Claims.Sudo. Every HTTP seam that turns a token into a principal goes through object.Verify, which stamps it on iam.User.Sudo (never decoded); IsSuperAdmin and ScopeOwner read that and compare no org. util.AdminOrg is gone; the rows that are the platform's own are named by authz.AdminOrg. With no host there is no SuperAdmin, and a ZAP door is not the host: target deletes X-User-IsAdmin from a ZAP-built request, and zapPrincipal carries a verdict only when the HTTP bridge vouched for the request it was handed. A key is never the SuperAdmin, as at the host.
24 lines
896 B
Go
24 lines
896 B
Go
// Copyright 2026 Hanzo AI Inc. All Rights Reserved.
|
|
|
|
package object
|
|
|
|
import "testing"
|
|
|
|
// The repository to read comes from the request, so whose credential reads it has
|
|
// to be the requester's — otherwise the platform's own access is spent on a
|
|
// target the caller chose, and whatever it can reach lands in the caller's index.
|
|
func TestARepositoryIsReadWithTheAskersCredential(t *testing.T) {
|
|
t.Setenv("GITHUB_TOKEN", "ghp-platform")
|
|
|
|
if got := resolveGitHubToken("", "acme"); got != "" {
|
|
t.Errorf("a tenant's ingest was given %q", got)
|
|
}
|
|
if got := resolveGitHubToken("ghp-theirs", "acme"); got != "ghp-theirs" {
|
|
t.Errorf("a tenant's own credential was not used: %q", got)
|
|
}
|
|
// The reserved org is the platform, so its ingests reach the platform's repos.
|
|
if got := resolveGitHubToken("", "admin"); got != "ghp-platform" {
|
|
t.Errorf("the platform's own ingest got %q", got)
|
|
}
|
|
}
|