Documentation
¶
Overview ¶
Package usernames holds the static rules for the usernames authn issues, so every component that names a user (authn's name guard, an access-request form, an approval controller) decides from one definition rather than a copy.
The rules here need no cluster: they are what a public form may check. Whether a name is already claimed, provisioned or granted rights by a binding is decided in-cluster, by authn's guard and at an administrator's approval, never on a public endpoint, so nobody can enumerate who exists.
Index ¶
Constants ¶
const ( // BoundedMinLen is the shortest maxLen Bounded accepts: a one-character // prefix, the marker and the hash. BoundedMinLen = 1 + len(boundedMarker) + boundedHashLen )
The parts of a hashed Bounded result: p + boundedMarker + 12 hex digits.
const MaxLength = kubeutil.DNS1123NameMaximumLength
MaxLength is the longest username authn issues for an identity source: Normalize cuts a longer one to this length, so it would be issued as another name.
Variables ¶
var ( ErrEmpty = errors.New("the username is empty") ErrNotIssued = errors.New("authn would issue the username in another form") ErrReserved = errors.New("the username is reserved") ErrTooLong = errors.New("the username is longer than authn issues") )
The reasons Check refuses a username.
Functions ¶
func Bounded ¶ added in v1.58.0
Bounded maps an issued username u to a DNS-1123 label of at most maxLen characters, for a consumer that needs one per username: the tenant policy names a tenant's namespace tenant-<Bounded(u, 56)> (acmp's tenant-policy design, §2.5). authn stamps it as the label authn.krateo.io/username-label.
- plain: u itself, when u is a DNS-1123 label of at most maxLen characters with no "--". Every existing label-shaped username keeps its value.
- hashed: otherwise p + "--" + the first 12 hex digits of sha256(u), where p is u with every character outside [a-z0-9-] replaced by '-', cut to maxLen-14.
Plain results never contain "--" and hashed ones always do, so the two sets are disjoint: no plain username can equal another user's hashed form. Two hashed results meet only if their names share the prefix and 48 bits of sha256.
u is an issued username, so it starts with [a-z0-9] (endpoints.ExactSecretName accepts no other), and so does p. The algorithm and the bound are frozen: a change would label one person's new Secret differently from their old one, so it needs a versioned migration planned with the tenant-policy owner.
maxLen must be at least BoundedMinLen and at most 63; Bounded panics otherwise, since the caller's constant is wrong.
func Check ¶
Check reports whether an identity source can be given username as it is: non-empty, at most MaxLength, already in the form authn issues (so the name a person asks for is the name they sign in as, and its credential Secret is endpoints.SecretName(username)), and not reserved. It reads no cluster state. A component may add its own limits on top (a tenant namespace named after the user, say).
func Normalize ¶
Normalize is the username authn issues for an identity source's name: it makes the name DNS-1123 compatible (kubeutil.MakeDNS1123Compatible), as the OAuth and OIDC logins do with preferred_username.
func ReservedNames ¶
func ReservedNames() []string
ReservedNames returns the exact usernames that are reserved.
func ReservedPrefixes ¶
func ReservedPrefixes() []string
ReservedPrefixes returns the prefixes that reserve every username they start.
Types ¶
This section is empty.