Documentation
¶
Overview ¶
Package apitoken provides shared helpers for generating opaque, random API token IDs and secrets, and computing safe display prefixes.
Index ¶
Constants ¶
const ( // TokenIDPrefix is the prefix for the public, opaque token ID. TokenIDPrefix = "tok_" // SecretPrefix is the prefix for the plaintext token secret. New tokens // use "apt_"; migrated legacy tokens keep their original value (e.g. // "ap_") so they continue to authenticate after migration. SecretPrefix = "apt_" )
Variables ¶
This section is empty.
Functions ¶
func DisplayPrefix ¶
DisplayPrefix returns a safe, short prefix of the secret for display.
func GenerateSecret ¶
GenerateSecret returns a new plaintext token secret: "apt_" + 32 random bytes hex.
func GenerateTokenID ¶
GenerateTokenID returns a new opaque token ID: "tok_" + 16 random bytes hex.
func MigrationTokenID ¶
MigrationTokenID returns a deterministic token ID derived from a migration source identifier. Migration IDs are stable so the migration is idempotent across restarts: re-running migration against the same legacy source resolves to the same new token ID and Create returns ErrAPITokenAlreadyExists, which the migration treats as "already migrated".
The returned ID is sanitized to be a valid Kubernetes resource-name suffix (lowercase, alphanumerics and dashes only).
Types ¶
This section is empty.