mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
IsSuperAdmin folded the case of the home org and fell back to the owner claim, the org of the application that minted the token, and the money bits were granted on X-User-Owner == admin. Cloud writes X-User-Owner for an admin-org application and an admin-org person's API key as well as for a person, so either could mint money and edit the catalog here while being nobody in the rest of the same process. Every gate now reads X-User-IsAdmin, which the edge strips and writes from authz.Claims.Sudo alone; the standalone EdgeAuth decides it with that predicate over the verified token's signed membership set. X-User-IsAdmin no longer doubles as the org-admin bit, which is X-User-IsOrgAdmin. No machine is SuperAdmin. Global admin is SuperAdmin wherever it named this predicate.
17 lines
564 B
Go
17 lines
564 B
Go
// Copyright (c) 2014-present Hanzo AI, Inc.
|
|
// Licensed under MIT OR Apache-2.0. See LICENSE-MIT and LICENSE-APACHE.
|
|
|
|
package auth
|
|
|
|
import "testing"
|
|
|
|
// The `owner` claim is the org of the APPLICATION a token was minted through, not
|
|
// the subject's, so it is never SuperAdmin on its own — in any case or padding.
|
|
func TestIAMClaims_OwnerClaimIsNotSuperAdmin(t *testing.T) {
|
|
for _, owner := range []string{"admin", "Admin", "ADMIN", " admin "} {
|
|
if (&IAMClaims{Owner: owner}).IsSuperAdmin() {
|
|
t.Errorf("owner claim %q read as SuperAdmin", owner)
|
|
}
|
|
}
|
|
}
|