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

Add token_reviewer_jwt as login parameter #227

Open
denniskniep opened this issue Jan 17, 2024 · 0 comments
Open

Add token_reviewer_jwt as login parameter #227

denniskniep opened this issue Jan 17, 2024 · 0 comments

Comments

@denniskniep
Copy link

For cases where we want to make use of short-lived k8s service account tokens, it would make sense to pass also the token_reviewer_jwt as parameter to the login endpoint. So that we pass two tokens:

  1. jwt = k8s service account token jwt for authenticating with vault (including an appropriate audience for vault)
  2. token_reviewer_jwt = k8s service account token jwt for authenticating with kubernetes tokenreview api (including an appropriate audience for kubernetes)

see code for reference:

jwtStr, resp := b.getFieldValueStr(data, "jwt")

err = serviceAccount.lookup(ctx, client, jwtStr, role.Audience, b.reviewFactory(config))

// If we have a configured TokenReviewer JWT use it as the bearer, otherwise
// try to use the passed in JWT.
bearer := fmt.Sprintf("Bearer %s", jwt)
if len(t.config.TokenReviewerJWT) > 0 {
bearer = fmt.Sprintf("Bearer %s", t.config.TokenReviewerJWT)
}
setRequestHeader(req, bearer)

As an example this issue in cert-manager for reference:
cert-manager/cert-manager#6150 (comment)

Related cert-manager code

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

No branches or pull requests

2 participants