Skip to content

fix: request the audience of projected service account tokens - #603

Open
NopeCharon wants to merge 1 commit into
interlink-hq:mainfrom
NopeCharon:fix/projected-token-audience
Open

NopeCharon wants to merge 1 commit into
interlink-hq:mainfrom
NopeCharon:fix/projected-token-audience

Conversation

@NopeCharon

Copy link
Copy Markdown
Contributor

Summary

A serviceAccountToken projected volume source can ask for a token with a specific audience. Pods use this to authenticate to services outside the Kubernetes API with their service account: Vault's Kubernetes auth, cloud workload identity, or any OIDC relying party that checks aud.

remoteExecutionHandleProjectedSource built the TokenRequest without the audience, so the offloaded container always got a token for the API server's default audiences and the external service rejected it. This PR sets Spec.Audiences to the source's audience when it is not empty, as the kubelet does. A source without an audience still gets a token for the default audiences, so the usual service account volume is unchanged.

Tests:

  • new TestRemoteExecutionHandleProjectedSourceServiceAccountToken captures the TokenRequest sent to the API server, for a source with and without an audience. It checks the requested audiences, that the token stays bound to the pod, and that the returned token is written at the source's path.

The test fails without the change. go test -race ./pkg/... and golangci-lint run (v2.14.0, as in CI) pass.


Related issue : #602

@netlify

netlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for interlink-dev canceled.

Name Link
🔨 Latest commit e9c941a
🔍 Latest deploy log https://app.netlify.com/projects/interlink-dev/deploys/6aecae72e0c9e94d60e21e52

remoteExecutionHandleProjectedSource built the TokenRequest for a
serviceAccountToken projected source without its audience, so the
offloaded container always got a token for the API server's default
audiences. Pods that authenticate to an external service with their
service account (Vault's Kubernetes auth, cloud workload identity, any
OIDC relying party checking aud) had their token rejected on a virtual
node.

Like the kubelet, set Spec.Audiences to the source's audience when it is
not empty. A source without an audience still gets a token for the API
server's default audiences, as before.

The new test captures the TokenRequest sent to the API server for a
source with and without an audience, and checks the token returned for
it is written at the source's path.

Fixes interlink-hq#602

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
@NopeCharon
NopeCharon force-pushed the fix/projected-token-audience branch from 7c805a8 to e9c941a Compare November 5, 2026 16:27

This branch has not been deployed

No deployments
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