Documentation
¶
Overview ¶
Package tokenauth authenticates in-cluster callers by their projected ServiceAccount token. The caller sends an audience-bound token in a request header; the Authenticator reviews it with the API server (TokenReview), accepts only the configured ServiceAccount subjects, and caches each verdict by token hash for a short TTL. Denials are cached too, so a caller retrying a bad token does not turn into API-server QPS.
The egress broker authenticates agent pods with it, and the integration-controller's internal endpoint authenticates the status server. A token is an identity document, not a capability: whoever accepts it still decides what that identity may do.
Index ¶
Constants ¶
const DefaultTTL = time.Minute
DefaultTTL is how long a verdict is cached when Config.TTL is unset.
const PodNameExtraKey = "authentication.kubernetes.io/pod-name"
PodNameExtraKey is where the API server reports the bound pod of a pod-bound projected token on the TokenReview user info.
Variables ¶
This section is empty.
Functions ¶
func ServiceAccount ¶
ServiceAccount renders the TokenReview username of a ServiceAccount.
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator validates caller tokens via TokenReview, caching verdicts by token hash for the configured TTL.
func New ¶
func New(cs kubernetes.Interface, cfg Config) *Authenticator
New builds an Authenticator; cs performs the TokenReviews.
func (*Authenticator) Authenticate ¶
Authenticate resolves the token in the request's header to an identity, reviewing it with the API server on a cache miss. The error string is safe to return to the caller (it never echoes the token).
type Config ¶
type Config struct {
// Audience is the projected-token audience callers must present.
Audience string
// Subjects are the only accepted usernames, e.g.
// system:serviceaccount:patchy:patchy-status-server.
Subjects []string
// TTL is how long one token's verdict is cached; <= 0 means DefaultTTL.
TTL time.Duration
}
Config configures an Authenticator.