Open
Conversation
Implement a Kubernetes-specific JWT provider that uses the pod's Service Account token and CA certificate for authenticating requests to the Kubernetes API server's OIDC endpoints. This approach avoids requiring RBAC policy changes that would otherwise be needed to allow anonymous access to the OIDC discovery and JWKS endpoints. Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Author
|
@hashicorp/vault-ecosystem, @fairclothjm, please take a look when you have time 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This change implements a Kubernetes-specific JWT provider that uses the pod's Service Account token and CA certificate for authenticating requests to the Kubernetes API server's OIDC endpoints.
This approach avoids requiring RBAC policy changes that would otherwise be needed to allow anonymous access to the OIDC discovery and JWKS endpoints.
The provider is configured in following way
The provider uses the default mount paths
/var/run/secrets/kubernetes.io/serviceaccount/tokenand/var/run/secrets/kubernetes.io/serviceaccount/ca.crtwhich removes burden from user to configure anything further than setting the discovery URL and selecting the Kubernetes provider. The default automounted token is sufficient, no RBAC permissions need to be created.Design of Change
This PR adds a new provider,
kubernetes, which implements the newKeySetDiscoveryinterface. This interface allows the provider to handle fetching the discovery document, keys and returnjwt.KeySet, enabling the Kubernetes provider to use a customhttp.RoundTripperfor authenticated all HTTP requests towards Kubernetes API server.The provider "re-implements" discovery document download itself (
retrieveJWKSURL, similar tojwt.NewOIDCDiscoveryKeySet()). This duplication could be eliminated if hashicorp/cap#176 is resolved.Related Issues/Pull Requests
Fixes #367
I have previously submitted this patch also to the OpenBao project openbao/openbao#2114
Contributor Checklist
[ ] Add relevant docs to upstream Vault repository, or sufficient reasoning why docs won’t be added yet
My Docs PR Link
Example
[ ] Add output for any tests not ran in CI to the PR description (eg, acceptance tests)
[ ] Backwards compatible
PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
If applicable, I've documented the impact of any changes to security controls.
Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.