identity

package
v0.1.30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package identity builds the cross-workspace ServiceAccount identity faros authorizes foreign SAs under.

kcp ServiceAccount usernames ("system:serviceaccount:{ns}:{name}") are logical-cluster-scoped — the same string means a DIFFERENT principal in every workspace, so binding RBAC to it in a tenant workspace would also match a same-named SA the tenant created themselves.

kcp already defines the disambiguated form: the GlobalServiceAccount feature gate (beta, default-on since kube 1.35 in the kcp fork) makes kcp's RBAC resolution alias every SA to

system:kcp:serviceaccount:{cluster}:{ns}:{name}

(see EffectiveUsers in the fork's pkg/registry/rbac/validation/kcp.go and kcp's e2e TestAPIResourceSchemaVirtualWorkspaceAuthorization, which binds exactly this subject across workspaces). Faros emits the same format — after verifying the home cluster via TokenReview — so the grant objects created on tenant Enable use kcp-native subjects: the same binding that satisfies faros's delegated SAR also authorizes the SA on kcp-native paths.

Both sides — the SAR caller in pkg/virtual/builder and the grant writer in pkg/hub/kcp — MUST use these helpers so the encodings cannot drift.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocalFromQualified

func LocalFromQualified(s string) (string, bool)

LocalFromQualified strips the home-cluster segment from a global SA username ("system:kcp:serviceaccount:{cluster}:{ns}:{name}") to produce the plain local form ("system:serviceaccount:{ns}:{name}") — the form kcp uses when it does NOT qualify a ServiceAccount to a home cluster (e.g. the token carries no verified cluster claim). Grant writers bind this ALONGSIDE the qualified form so a cross-workspace provider SA is authorized whether or not kcp qualified it on the request path. Returns false if s is not a global SA username.

func QualifiedServiceAccount

func QualifiedServiceAccount(homeCluster, namespace, name string) string

QualifiedServiceAccount builds the global username from parts. Used by the grant writer, which knows the SA's coordinates rather than holding a TokenReview result.

func QualifyServiceAccount

func QualifyServiceAccount(homeCluster, saUsername string) (string, bool)

QualifyServiceAccount converts a TokenReview-resolved ServiceAccount username ("system:serviceaccount:{ns}:{name}") plus its verified home logical cluster into kcp's global form "system:kcp:serviceaccount:{homeCluster}:{ns}:{name}".

Returns false when saUsername is not a ServiceAccount username.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL