Skip to content

fix: generate valid EKS authentication token payload#4779

Merged
k8s-ci-robot merged 1 commit into
kubernetes-client:masterfrom
hwayoungjun:fix/eks-authentication-401
May 29, 2026
Merged

fix: generate valid EKS authentication token payload#4779
k8s-ci-robot merged 1 commit into
kubernetes-client:masterfrom
hwayoungjun:fix/eks-authentication-401

Conversation

@hwayoungjun
Copy link
Copy Markdown
Contributor

Description

EKSAuthentication currently URL-encodes the entire presigned STS GetCallerIdentity URL before building the k8s-aws-v1. bearer token.

However, the presigned URL returned by the AWS signer already contains encoded query parameters. Encoding the entire URL again makes the decoded token payload an encoded URL string, rather than the presigned STS URL form used by aws-iam-authenticator and shown in the EKS docs.

For example, the decoded token payload form is:

https://sts.ap-northeast-2.amazonaws.com/?Version=2011-06-15&Action=GetCallerIdentity&X-Amz-Credential=...%2F...

With the extra full-URL encoding step, the decoded payload instead becomes an encoded URL string:

https%3A//sts.ap-northeast-2.amazonaws.com%3FVersion%3D2011-06-15%26Action%3DGetCallerIdentity%26X-Amz-Credential%3D...%252F...

I observed this causing EKS API requests using EKSAuthentication to fail with 401 Unauthorized.

This change builds the EKS bearer token from the presigned STS URL directly. It also sets the STS request path explicitly to /, matching the working presigned URL form verified against EKS:

https://sts...amazonaws.com/?...

Changes

  • Stop URL-encoding the entire presigned STS URL before base64url-encoding it
  • Set the STS request path explicitly to /

References

Validation

I verified this manually against a real EKS cluster by using EKSAuthentication to generate the bearer token and calling CoreV1Api.listNamespace().

The previous token payload failed with 401 Unauthorized, while the updated payload succeeded in listing namespaces.

Build the EKS bearer token from the presigned STS GetCallerIdentity URL
directly instead of URL-encoding the whole presigned URL first. The AWS
signer already returns a URL with encoded query parameters, and encoding
the entire URL again makes the decoded token payload an encoded URL string
rather than the presigned STS URL expected by EKS.

Set the STS request path explicitly to "/" so the generated presigned URL
matches the accepted EKS token payload shape.

This fixes EKSAuthentication requests failing with 401 Unauthorized.
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 20, 2026
@brendandburns
Copy link
Copy Markdown
Contributor

/lgtm
/approve

I'm trusting this since I don;t have an EKS cluster to validate on. We'll revert if it breaks people.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 29, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, hwayoungjun

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 29, 2026
@k8s-ci-robot k8s-ci-robot merged commit 99cc0b6 into kubernetes-client:master May 29, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants