feat(identity): resolve identity through Kubernetes TokenReview #361
All Vouch review confidence checks passed
Residual risk 0.32 = Change Risk (0.75) × (1 − Review Confidence (0.58)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.75 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.075
Real PR Conversation Timeline
1 comments
"Review active on #361"
general
weight: 0.35
guicassolato
Closes: #213
This PR adds
identity/kubernetes-token-review, which sends the presented token to the API server's TokenReview API and maps the user the cluster names onto the identity slots. For a ServiceAccount JWT that only needs its signature checked,identity/jwtagainst the cluster issuer is still the cheaper option, and Recipe 12 says so.Two commits
1.
refactor(builtins)moves the parts ofidentity/api-keythat are not specific to API keys into a crate-privatetoken_lookupmodule: theKeyDirectorytrait, the cache, credential hashing and theidentity.resolvehandler. A smallLookupProfileholds what differs between plugins (the unknown and expired denial codes, and the cache's hashing labels).identity_api_keyre-exportscache,directoryand itscodes, so every public path is unchanged and the API key tests pass without edits. The module doc states the rule that keeps it small: a mechanism that needs a branch in the shared resolver gets its own plugin.2.
feat(identity)adds the plugin as aKeyDirectorybackend on that core, behind thekubernetes-token-reviewfeature, also in the facade'sbuiltins.Configuration
reread_secshas passed (default 60) so a projected token rotates, or from an environment variable read once. Its identity needscreateontokenreviews, whichsystem:auth-delegatorgrants. A failed re-read keeps the last token. Thesecrets:block is not used because plugins cannot read the secret store today.api_server.urlmust behttps://, because the reviewer token travels on it.spec.audiencesand also checked againststatus.audiences. With none set, any token the cluster accepts for its own API signs a caller in, and the plugin warns at load. Legacy Secret tokens authenticate only for the API server's audience, so a deployment serving them leavesaudiencesunset.status.useras the API server returns it:username,uid,groups,extra.exp, read without verification from a token the API server just authenticated.perform_httpis required at load, not discovered on the first request.| Outcome | Code |
|---|---|
| Not authenticated, or not for a configured audience |
auth.token_unauthenticated|| A cached answer outlived the JWT's
exp|auth.token_expired||
401or403(PPE's own token was refused), 5xx, timeout, unreadable answer |auth.directory_unavailable|The API server answers
201for both outcomes and omitsauthenticatedwhen it is false, so the verdict is read from the body and a missing field is a refusal.Testing
The plugin has 21 tests. The API server's answers in
tests/token_review/fixtures/were captured from Kubernetes 1.35 (kind), with the echoedspec.tokenredacted: a projected token, a legacy token with and without a custom audience, a legacy token after its Secret was deleted, an unknown token, and a reviewer without RBAC. One test builds Recipe 12's exactconfig:block from the docs.End to end, Praxis
upstream/mainbuilt against this branch, withSSL_CERT_FILEpointing at the cluster CA, reviewed every request against kind: a team-a token reached the backend, a team-b token was denied by the role check, and default-audience, custom-audience legacy, unknown and revoked legacy tokens were refused. Praxis compiled against 0.7.0 with no source changes.One finding from that run is in the docs: the API server caches successful authentications for about 10 seconds, so a token whose Secret was just deleted keeps passing for that long, on top of PPE's cache TTL.
make check,lint,doc,check-features,test(both passes) andtest-fips-no-providerare clean.Breaking changes
None. Public paths and codes of
identity/api-keyare unchanged. The only behaviour change is one log message from the shared resolver, which now says "credential directory could not answer" instead of "api key directory could not answer".Not in this PR
secret:source for the reviewer token, once plugins can read the secret store.HyperTransport, which today trusts only the public roots and so cannot reach a cluster API server. Praxis is unaffected. To be filed separately.api_server.<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Added Kubernetes
TokenReviewidentity resolution, mapping authenticated Kubernetes user details to identity attributes, including tokens that cannot be verified locally.Added configurable audiences, reviewer credentials from environment variables or refreshed files, HTTPS API-server configuration, request timeouts, and optional caching. Cached results do not outlive parseable JWT expiration.
Added the feature to bundled plugin options and documented setup and configuration.
Bug Fixes
Unauthenticated reviews and Kubernetes API authorization failures deny access; API
401and403responses report the directory as unavailable.<!-- end of auto-generated comment: release notes by coderabbit.ai -->