Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #561 +/- ##
==========================================
- Coverage 61.56% 59.57% -2.00%
==========================================
Files 11 11
Lines 752 705 -47
==========================================
- Hits 463 420 -43
+ Misses 274 268 -6
- Partials 15 17 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1f54410 to
9d3e691
Compare
simonmarty
requested changes
Feb 3, 2026
e3609ce to
9916ea1
Compare
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.
Issue #, if available:
#400, #422
Description of changes:
Summary
This PR adopts the CSI driver's
tokenRequestsmechanism for obtaining pod service account tokens. CSI Token Requests is the standard way for CSI drivers to impersonate the pods they mount volumes for — the driver mints service account tokens on behalf of each pod and passes them to the provider. Previously, the provider minted these tokens itself using the K8s TokenRequest API, which requiredserviceaccounts/token createRBAC permission. With this change, the provider receives pre-minted tokens from the CSI driver, eliminating that permission and simplifying the provider's role to consuming tokens rather than creating them. Instead of minting Kubernetes service account tokens itself (via the TokenRequest API), the provider now receives pre-minted tokens from the CSI driver through the standardtokenRequestsmechanism.Motivation
Previously, the provider held a Kubernetes client and called the TokenRequest API directly to create service account tokens for both IRSA (
sts.amazonaws.comaudience) and Pod Identity (pods.eks.amazonaws.comaudience). This required:serviceaccounts/tokencreatepermission in the ClusterRoleThe CSI driver already supports a
tokenRequestsfeature that projects service account tokens into the mount request attributes. By leveraging this, the provider becomes a simpler consumer of pre-fetched tokens rather than an active participant in token creation.How it works
The CSI driver's
CSIDriverresource is configured withtokenRequestsspecifying the required audiences:On each mount (and remount during rotation), the CSI driver mints fresh tokens via the K8s TokenRequest API and passes them to the provider in the
csi.storage.k8s.io/serviceAccount.tokensvolume attribute. The provider parses this JSON, extracts the token for the appropriate audience (IRSA or Pod Identity), and passes it to the credential provider.Before:
After:
Changes by file
Deleted files
auth/auth.go(113 lines) — The entire auth orchestration package is removed. This contained theAuthstruct,NewAuth()constructor,GetAWSConfig()dispatcher,getAppID()helper, and theProviderVersion/ProviderNameconstants. All of this functionality is either inlined into the server or eliminated.auth/auth_test.go(221 lines) — All tests for the auth package (TestNewAuth,TestGetAWSConfig,TestAppID).New files
utils/token_parser.go(42 lines) — DefinesParseServiceAccountTokens()which parses the CSI driver'sserviceAccount.tokensJSON into amap[string]ServiceAccountToken, andGetTokenForAudience()which extracts a non-empty token for a specific audience. Also defines theIRSAAudienceandPodIdentityAudienceconstants. Error messages explicitly point totokenRequestsconfiguration as the fix, since a missing/empty tokens attribute is the most likely misconfiguration.utils/token_parser_test.go(134 lines) — Table-driven tests for both functions covering: empty input, invalid JSON, valid multi-audience, valid single-audience, missing audience, empty token value, and audience constant validation.Application code changes
server/server.go— The core integration point.Mount()now extractsserviceAccount.tokensfrom the mount attributes, callsParseServiceAccountTokens()upfront, then usesGetTokenForAudience()to select the right token based onusePodIdentity. ThegetRoleARN()method (previously inIRSACredentialProvider) is moved here since the server already has the K8s client. TheappID()method andProviderName/ProviderVersionconstants are moved from the deletedauthpackage.getAwsConfigs()signature changes to acceptroleArnandtokendirectly instead of namespace/serviceAccount/podName. A pre-existing bug in thelen(awsConfigs) > 2guard was fixed — it previously returnednil, errwhereerrwas nil (from the preceding successfulgetAwsConfigscall), now returns a proper error.credential_provider/irsa_credential_provider.go— Significantly simplified. TheirsaTokenFetcher(which called the K8s TokenRequest API) is replaced withcsiTokenFetcher, a trivial struct that returns a pre-fetched token string to satisfy thestscreds.IdentityTokenRetrieverinterface.NewIRSACredentialProvider()now takes(region, roleArn, appID, token string)instead of(stsClient, region, namespace, serviceAccount, appID, k8sClient).getRoleARN()is moved to the server.GetAWSConfig()creates an STS client inline rather than receiving one.credential_provider/pod_identity_credential_provider.go— Same pattern. ThepodIdentityTokenFetcher(K8s TokenRequest API with BoundObjectRef) is replaced withcsiTokenProvider, a trivial struct returning a pre-fetched token for theendpointcreds.AuthTokenProviderinterface.NewPodIdentityCredentialProvider()drops thenamespace,serviceAccount,podName, andk8sClientparameters, takingtoken stringinstead. No more input validation for nil K8s client.credential_provider/credential_provider.go— Unchanged. TheConfigProviderinterface remains the same.main.go— Removes theauthpackage import. Changesauth.ProviderNametoserver.ProviderName. Adds a startup log message:"This provider requires tokenRequests to be configured in the CSIDriver spec".Test changes
server/server_test.go—buildMountReq()now injects CSI tokens JSON into the mount attributes (both IRSA and Pod Identity tokens with far-future expiration). Error message assertions updated from"An IAM role must be associated"to"IAM role must be associated".auth.ProviderNamereferences changed toProviderName. Four new tests added:TestMountMissingTokensAttribute— verifies the error whenserviceAccount.tokensis absent from mount attributesTestMountTokenAudienceMismatch— verifies the error whenusePodIdentity=truebut only the IRSA token audience is presentTestMountMaxRegionsExceeded— validates the max-regions guard doesn't false-positive (and that the bug fix returns a real error)TestAppID— table-driven test forappID()with and without EKS addon version override (coverage moved from deletedauth_test.go)credential_provider/credential_provider_test.go— All mock types removed (mockSTS,mockK8sV1,mockK8sV1SA). Only shared test constants remain.credential_provider/irsa_credential_provider_test.go— Rewritten from 172 to ~51 lines. Complex mock-based tests replaced with simple tests:TestNewIRSACredentialProvider,TestCSITokenFetcher,TestIRSACredentialProvider_GetAWSConfig.credential_provider/pod_identity_credential_provider_test.go— Reduced from 489 to ~100 lines. Complex mock infrastructure removed. New simple tests plus two new dual-stack tests:TestPodIdentityCredentialProvider_GetAWSConfig_AutoFallback— verifies IPv6 works when IPv4 is unreachableTestPodIdentityCredentialProvider_GetAWSConfig_BothFail— verifies failure when both endpoints are unreachableRBAC changes
charts/secrets-store-csi-driver-provider-aws/templates/rbac.yaml— Removes theserviceaccounts/tokencreaterule from the ClusterRole.deployment/aws-provider-installer.yaml— Same removal, plus addstolerations: [{operator: Exists}]for EKS Auto Mode compatibility.deployment/private-installer.yaml— Same removal and toleration addition.Helm chart changes
charts/secrets-store-csi-driver-provider-aws/values.yaml— AddstokenRequestsconfiguration to the CSI driver sub-chart dependency, specifying both audiences (sts.amazonaws.comandpods.eks.amazonaws.com).CI changes
.github/workflows/docker-image.yml— Build arg changed fromauth.ProviderVersiontoserver.ProviderVersion..github/workflows/integ.yml— Same change.Makefile— LDFLAGS changed fromauth.ProviderVersiontoserver.ProviderVersion.Documentation changes
README.md— Adds a new "Separate CSI Driver Installation" section explaining how to configuretokenRequestswhen installing the CSI driver separately (both Helm and kubectl examples).Integration test changes
tests/integration.bats.template— Adds--set tokenRequests[0].audience=sts.amazonaws.com --set tokenRequests[1].audience=pods.eks.amazonaws.comto the Helm install command. Adds a new test case"Verify serviceaccounts/token create permission is not granted to provider"that checks the ClusterRole.Testing
arm-irsa,arm-pod-identity,x64-irsa,x64-pod-identity) including rotation tests, confirming the CSI driver correctly passes fresh tokens on remountBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.