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

Use CSI TokenRequest for obtaining service account tokens #400

Open
dronenb opened this issue Oct 23, 2024 · 1 comment
Open

Use CSI TokenRequest for obtaining service account tokens #400

dronenb opened this issue Oct 23, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@dronenb
Copy link

dronenb commented Oct 23, 2024

Other providers for the Secrets Store CSI driver leverage the CSI driver's (not the provider's) ability to obtain service account tokens for pods that use that CSI driver (see here). This way, the providers nor the driver need the create serviceaccounts/token role.

Code in question:

func (p authTokenFetcher) FetchToken(ctx credentials.Context) ([]byte, error) {
// 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{tokenAudience},
},
}, metav1.CreateOptions{})
if err != nil {
return nil, err
}
return []byte(tokRsp.Status.Token), nil
}

Examples of this from other providers:

https://github.com/GoogleCloudPlatform/secrets-store-csi-driver-provider-gcp/blob/main/auth/auth.go#L187-L198

https://github.com/Azure/secrets-store-csi-driver-provider-azure/blob/41b07df322b82a56915ba63abb56c16c37730d33/pkg/auth/auth.go#L304-L327

Without this, the AWS provider will continue to be over-privileged.

@dronenb dronenb added the enhancement New feature or request label Oct 23, 2024
@jirkafajfr
Copy link
Member

Thank you @dronenb, we've noted this as a feature request.

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