mirror of
https://github.com/hanzoai/k8s.git
synced 2026-10-02 15:40:05 +00:00
The tree was staged but never committed — this is the repo's first commit, so it carries both the existing content and the zip v1.18.8 -> v1.20.0 migration. Migration: Prepare() is replaced by Build() error, and both test harnesses assert the verdict rather than discarding it. main.go:59's Use call needed no change — the three middleware constructors already return zip.Handler, which satisfies the closed Component interface. The committed projections (k8s.plugin.json, openapi.json, ops/zipdoc_gen.go) are regenerated: v1.20.0 splits an op's prose into summary (first line) + description and zipdoc now emits per-field docs, so all three artifacts move with the bump. Co-authored-by: Hanzo Dev <[email protected]>
34 lines
1.2 KiB
Go
34 lines
1.2 KiB
Go
package registry
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/zap-proto/zip"
|
|
)
|
|
|
|
// Tenant is the org this call may act for, or a refusal.
|
|
//
|
|
// It is zip.Tenant plus one thing zip cannot know: the org becomes a KMS ref
|
|
// SEGMENT here, so a value containing '/' would address material outside the
|
|
// org's own prefix. That is a property of this app's storage, not of the
|
|
// framework's identity model, so it is checked here and only here.
|
|
//
|
|
// zip.Tenant is the FULL rule and not a non-empty check — no validated user claim
|
|
// means the org that rode along is a claim the caller made about itself, an empty
|
|
// org is a refusal, and an org over zip.MaxOrgLen is a refusal because the value
|
|
// is retained past the request as a store key. The org is used VERBATIM: trimmed,
|
|
// never lower-cased and never truncated, because folding collapses "acme",
|
|
// "ACME" and a 32-character prefix into one bucket, which is itself a
|
|
// cross-tenant break.
|
|
func Tenant(ctx context.Context) (string, error) {
|
|
org, ok := zip.Tenant(ctx)
|
|
if !ok {
|
|
return "", ErrNoTenant{}
|
|
}
|
|
if strings.ContainsAny(org, "/\\") || strings.Contains(org, "..") {
|
|
return "", ErrNoTenant{}
|
|
}
|
|
return org, nil
|
|
}
|