Add Kubernetes TokenReview support to K8sSA provisioner - #2760
Open
murzakanovim wants to merge 1 commit into
Open
Add Kubernetes TokenReview support to K8sSA provisioner#2760murzakanovim wants to merge 1 commit into
murzakanovim wants to merge 1 commit into
Conversation
Authenticate Kubernetes ServiceAccount tokens with the in-cluster TokenReview API when publicKeys is omitted. Preserve the existing public-key mode, route modern projected tokens, and document the required RBAC and audience configuration.
murzakanovim
force-pushed
the
codex/k8ssa-tokenreview
branch
from
August 6, 2026 14:57
4689c4a to
d377c99
Compare
murzakanovim
marked this pull request as ready for review
August 6, 2026 14:58
Author
|
@dopey Hi Max! Can u review this pr? You left TODO 7 years ago, I think its time to implement TokenReview way |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
publicKeysis configuredBehavior
When a K8sSA provisioner omits
publicKeys, step-ca initializes a minimalin-cluster TokenReview client using the standard Kubernetes API environment,
mounted CA bundle, and ServiceAccount credential. If
publicKeysis present,the existing local JWT verification behavior is unchanged.
The TokenReview request includes the operation-specific step-ca audiences. The
response must be authenticated and contain an audience accepted by the current
sign, revoke, or SSH-sign endpoint. The authenticated username must use the
standard
system:serviceaccount:<namespace>:<name>form; namespace,ServiceAccount name, and UID are populated from the TokenReview response rather
than unverified JWT claims.
Modern ServiceAccount tokens no longer have a fixed issuer. Routing therefore
uses the standard ServiceAccount subject plus Kubernetes claims as an
unverified hint. The selected K8sSA provisioner still authenticates the token
with TokenReview before trusting any identity.
The implementation fails closed. It does not fall back to public-key
validation when the Kubernetes API is unavailable. The reviewer credential is
read on every request so kubelet rotation is picked up without a restart.
Scope
This implements the generic same-cluster path only. It does not add remote
kubeconfig or multi-cluster routing. K8sSA certificate CN/SAN authorization is
unchanged and remains the responsibility of name policy, templates, or
webhooks.
Verification
go test ./authority/provisionergo test -short ./...go test -race ./authority/provisionergo vet ./...Design feedback requested
publicKeysthe preferred opt-in for in-cluster TokenReview,or should this be represented by an explicit configuration field?
step-ca endpoint instead of accepting the Pod's default Kubernetes API
audience. Is that strict audience behavior desirable for K8sSA?