Skip to content

feat(nvct): accept delegated projected ServiceAccount tokens for task worker auth - #849

Draft
estroz wants to merge 1 commit into
mainfrom
feat/nvct-api-delegated-worker-tokens
Draft

feat(nvct): accept delegated projected ServiceAccount tokens for task worker auth#849
estroz wants to merge 1 commit into
mainfrom
feat/nvct-api-delegated-worker-tokens

Conversation

@estroz

@estroz estroz commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Why

Part of the delegated worker token feature (issue #840). On self-hosted NVCT clusters, task workers receive a projected Kubernetes ServiceAccount Token (PSAT) mounted into their pods. The existing path decodes a Notary-issued assertion JWT, which the PSAT is not. This PR adds a fallback so WorkerAssertionValidator calls ICMS token introspection when Notary decode fails, enabling task workers to authenticate via cluster OIDC.

What changed

  • IcmsStubService: Added WorkerTokenIntrospectRequest/WorkerTokenIntrospectResult DTOs and the introspectWorkerToken HTTP exchange method targeting POST /v1/workers/tokens/introspect.

  • IcmsClient: Delegating wrapper for introspectWorkerToken.

  • WorkerTokenIntrospectionService (new): Caffeine-backed cache keyed on SHA-256(token), evicted after 14 minutes. Inactive results are never cached. Gated on nvct.worker.delegated-token-enabled.

  • WorkerAssertionValidator.validate: Wraps validateNotaryJwt in try/catch. When ForbiddenException is thrown and the flag is on, falls through to ICMS introspection. active=true → authorized. active=false → re-throw forbidden.

  • application.yaml: Added nvct.worker.delegated-token-enabled: false (default). Self-hosted Helmfile overlay sets it to true.

Customer Release Notes

Not customer visible — self-hosted infrastructure change.

Plan Summary

Not applicable.

Usage

Enable on self-hosted clusters by setting nvct.worker.delegated-token-enabled: true in the Helmfile values overlay. No changes needed for managed NVCT.

Testing

Notes

NVCT task workers use WorkerAssertionValidator.validate directly (no gRPC issued-token flow). The Notary JWT path remains unchanged when the flag is off.

References

Relates to #840

Related Pull Requests

Dependencies

No new third-party dependencies. Caffeine is already used in IcmsClient.

Summary by CodeRabbit

  • New Features

    • Added support for introspecting worker tokens to determine their validity, status, and associated metadata.
    • Added optional delegated-token authentication fallback when standard token validation fails.
    • Added caching for active token introspection results to improve repeated authorization checks.
  • Configuration

    • Added a setting to enable or disable delegated-token support, disabled by default.
  • Tests

    • Added coverage for token introspection, caching behavior, feature flags, and request handling.

… worker auth

Adds a fallback token validation path for self-hosted NVCT clusters where
workers present a projected Kubernetes ServiceAccount Token (PSAT) instead
of the Notary-issued assertion JWT.  When Notary JWT decoding fails and
nvct.worker.delegated-token-enabled=true, WorkerAssertionValidator calls
ICMS POST /v1/workers/tokens/introspect (RFC 7662) to verify the PSAT via
cluster OIDC.  Active results are cached in-process for up to 14 minutes.

Changes:
- IcmsStubService: add WorkerTokenIntrospectRequest/Result DTOs and
  introspectWorkerToken exchange method
- IcmsClient: delegate introspectWorkerToken to the stub
- WorkerTokenIntrospectionService (new): Caffeine cache + introspection
  wrapper gated on nvct.worker.delegated-token-enabled
- WorkerAssertionValidator: inject WorkerTokenIntrospectionService and
  catch ForbiddenException from Notary JWT validation, falling through to
  ICMS introspection when enabled
- application.yaml: add nvct.worker.delegated-token-enabled: false
  (overridden to true in self-hosted Helmfile overlay)

Relates to #840

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@estroz
estroz requested a review from a team as a code owner August 14, 2026 00:37
@estroz
estroz requested a review from borao August 14, 2026 00:37
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4fdcbb4f-5a33-46e5-a9e3-a2fcbc2a8d34

📥 Commits

Reviewing files that changed from the base of the PR and between 6dfc0e9 and b938ecf.

📒 Files selected for processing (6)
  • src/control-plane-services/cloud-tasks/nvct-core/src/main/java/com/nvidia/nvct/service/icms/IcmsClient.java
  • src/control-plane-services/cloud-tasks/nvct-core/src/main/java/com/nvidia/nvct/service/icms/IcmsStubService.java
  • src/control-plane-services/cloud-tasks/nvct-core/src/main/java/com/nvidia/nvct/service/token/WorkerAssertionValidator.java
  • src/control-plane-services/cloud-tasks/nvct-core/src/main/java/com/nvidia/nvct/service/token/WorkerTokenIntrospectionService.java
  • src/control-plane-services/cloud-tasks/nvct-core/src/test/java/com/nvidia/nvct/service/token/WorkerTokenIntrospectionServiceTest.java
  • src/control-plane-services/cloud-tasks/nvct-service/src/main/resources/application.yaml

📝 Walkthrough

Walkthrough

The change adds ICMS worker-token introspection models and client support. It adds cached introspection service logic. Worker assertion validation can accept active delegated tokens when enabled. Delegated-token support is disabled by default.

Changes

Delegated worker-token introspection

Layer / File(s) Summary
ICMS introspection contract
src/control-plane-services/cloud-tasks/nvct-core/src/main/java/com/nvidia/nvct/service/icms/IcmsStubService.java, src/control-plane-services/cloud-tasks/nvct-core/src/main/java/com/nvidia/nvct/service/icms/IcmsClient.java
Adds request and result DTOs and forwards introspection requests to POST /v1/workers/tokens/introspect.
Introspection service and cache
src/control-plane-services/cloud-tasks/nvct-core/src/main/java/com/nvidia/nvct/service/token/WorkerTokenIntrospectionService.java, src/control-plane-services/cloud-tasks/nvct-core/src/test/java/com/nvidia/nvct/service/token/WorkerTokenIntrospectionServiceTest.java
Adds SHA-256 cache keys, 14-minute caching for active results, inactive-result bypassing, enablement checks, and tests for cache and request behavior.
Validator fallback and configuration
src/control-plane-services/cloud-tasks/nvct-core/src/main/java/com/nvidia/nvct/service/token/WorkerAssertionValidator.java, src/control-plane-services/cloud-tasks/nvct-service/src/main/resources/application.yaml
Adds introspection fallback after failed Notary JWT validation and disables delegated-token support by default.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Mergeability Score: ⚪ Minimal · up to b938e

This change adds an opt-in delegated-token authentication path while preserving the existing behavior by default; no actionable merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant WorkerAssertionValidator
  participant WorkerTokenIntrospectionService
  participant IcmsClient
  participant IcmsStubService
  WorkerAssertionValidator->>WorkerAssertionValidator: Fail Notary JWT validation
  WorkerAssertionValidator->>WorkerTokenIntrospectionService: introspect(rawToken)
  WorkerTokenIntrospectionService->>IcmsClient: introspectWorkerToken(request)
  IcmsClient->>IcmsStubService: POST /v1/workers/tokens/introspect
  IcmsStubService-->>IcmsClient: WorkerTokenIntrospectResult
  IcmsClient-->>WorkerTokenIntrospectionService: Introspection result
  WorkerTokenIntrospectionService-->>WorkerAssertionValidator: Active or inactive result
Loading

Possibly related PRs

  • NVIDIA/nvcf#839: Provides the ICMS introspection endpoint and models consumed by this change.
  • NVIDIA/nvcf#846: Provisions worker identities and authentication metadata used by delegated-token validation.
  • NVIDIA/nvcf#848: Contains closely matching worker-token introspection and validation changes.

Suggested reviewers: borao

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses the required Conventional Commits format and accurately describes the delegated token authentication feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/nvct-api-delegated-worker-tokens

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

🛡️ CodeQL Analysis

🚨 Found 11 issue(s)

Severity Breakdown:

  • 🔴 Errors: 0
  • 🟡 Warnings: 0
  • 🔵 Notes: 0
📋 Top Issues

🔗 View full details in Security tab

🕐 Last updated: 2026-08-14 00:44:01 UTC | Commit: b938ecf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant