feat: container credential provider support auth token #106
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
This PR adds support for using authorization token in Container Credential Provider. Container Credential Provider uses two environment variables for the auth token content:
AWS_CONTAINER_AUTHORIZATION_TOKEN
(for token value) andAWS_CONTAINER_AUTHORIZATION_TOKEN_FILE
(for a file path that stores token value). See https://docs.aws.amazon.com/sdkref/latest/guide/feature-container-credentials.html. If one of the token env vars exists, the token value will be used asAuthorization
header value when requesting credential provider URI.By adding support for auth token in Container Credential Provider, we can support the latest "Pod Identity" IAM Auth method in AWS EKS. See How EKS Pod Identity works
Note that this PR only adds support for
AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE
. Due to the env isolation of Nginx worker process, the possible rotating ofAWS_CONTAINER_AUTHORIZATION_TOKEN
may not work if it is not defined in Nginx config. By searching through the AWS documentation it seems that there is only one IoT service "Greengrass" use that var to store raw token value, and Pod Identity always use token file. So I decide to add token file support at first, and leave the other one as a TODO.Reference:
https://github.com/aws/aws-sdk-js/blob/3276faf83e32dfea637797c66a73431affe54e64/lib/credentials/remote_credentials.js#L118C3-L118C18
https://konghq.atlassian.net/browse/KAG-3424