Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect Audience Annotation #388

Closed
aaronb-sb opened this issue Aug 6, 2024 · 1 comment
Closed

Respect Audience Annotation #388

aaronb-sb opened this issue Aug 6, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@aaronb-sb
Copy link

While EKS OIDC creation defaults to sts.amazonaws.com kops defaults to amazonaws.com, but the bigger thing is to be completely compliant with pod-identity-webhook the audience annotation must be respected instead of a hard coded constant.

Code Changes in auth.go

	arnAnno         = "eks.amazonaws.com/role-arn"
	audienceAnno    = "eks.amazonaws.com/audience"
	docURL          = "https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html"
	defaultAudience = "sts.amazonaws.com"
	ProviderName    = "secrets-store-csi-driver-provider-aws"
)

func (p authTokenFetcher) FetchToken(ctx credentials.Context) ([]byte, error) {
	svcAcc, err := p.k8sClient.ServiceAccounts(p.nameSpace).Get(ctx, p.svcAcc, metav1.GetOptions{})
	if err != nil {
		return nil, err
	}

	audience := svcAcc.Annotations[audienceAnno]
	if len(audience) <= 0 {
		audience = defaultAudience
	}

	// Use the K8s API to fetch the token from the OIDC provider.
	tokRsp, err := p.k8sClient.ServiceAccounts(p.nameSpace).CreateToken(ctx, p.svcAcc, &authv1.TokenRequest{
		Spec: authv1.TokenRequestSpec{
			Audiences: []string{audience},
		},
	}, metav1.CreateOptions{})
	if err != nil {
		return nil, err
	}

	return []byte(tokRsp.Status.Token), nil
}
@aaronb-sb aaronb-sb added the enhancement New feature or request label Aug 6, 2024
@simonmarty
Copy link
Contributor

Closing in favor of #300 , we're working on pod identity support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants