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

Error parsing non-legacy JWT claims for service account tokens #107

Closed
ljupchokotev opened this issue Jun 2, 2021 · 1 comment
Closed

Comments

@ljupchokotev
Copy link

ljupchokotev commented Jun 2, 2021

We are using the Vault CSI Driver which uses the Kubernetes Auth Method on Kubernetes v1.20. The CSI driver fails with the following message when trying to authenticate:

URL: POST https://vault/v1/auth/kubernetes/login
Code: 400. Errors:

* 1 error occurred:
	* error running lookahead function for mfa: could not parse UID from claims

This error comes from here. Vault expects a kubernetes.io/serviceaccount/service-account.uid claim in the JWT, which is only true for legacy JWT claims in Kubernetes.

The Vault CSI driver uses the api/v1/namespaces/<namespace>/serviceaccounts/<serviceaccount>/token endpoint in Kubernetes to manually create a JWT for a service account and then uses that JWT to authenticate to Vault. The JWT created via this endpoint is using an updated version of the claims, so there is a new structure which Vault can't process.

Example decoded tokens:

  1. Manually created JWT via the endpoint
{
  "aud": [
    "aud"
  ],
  "exp": 1622641490,
  "iat": 1622637890,
  "iss": "iss",
  "kubernetes.io": {
    "namespace": "namespace",
    "serviceaccount": {
      "name": "vault",
      "uid": "4bbf3254-3461-476d-a1f8-0bc9cc00831b"
    }
  },
  "nbf": 1622637890,
  "sub": "system:serviceaccount:namespace:vault"
}
  1. The automatically created token when creating the service account (from the <service-account-name>-token secret):
{
  "iss": "kubernetes/serviceaccount",
  "kubernetes.io/serviceaccount/namespace": "namespace",
  "kubernetes.io/serviceaccount/secret.name": "vault-token-5qmzb",
  "kubernetes.io/serviceaccount/service-account.name": "vault",
  "kubernetes.io/serviceaccount/service-account.uid": "4bbf3254-3461-476d-a1f8-0bc9cc00831b",
  "sub": "system:serviceaccount:namespace:vault"
}
@ljupchokotev ljupchokotev changed the title Error parsing non-legacy JWT claims for service account token Error parsing non-legacy JWT claims for service account tokens Jun 2, 2021
@ljupchokotev
Copy link
Author

This is fixed through our enterprise support.

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

No branches or pull requests

1 participant