fix: propagate http.Client to JWT verifier for OIDC connector #3641
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
The OIDC connector has two options that directly customize the http.Client used for requests:
rootCAs
andinsecureSkipVerify
(passed here to http.Client here).That customized http.Client isn't currently propagated through to the JWT verifier. This means that the verifier's requests to the JWKS endpoint can unexpectedly fail with certificate issues.
Example of an error caused by this inconsistency
Truncated sample configuration describing our setup:
Dex's communication with the provider should be inside the Kubernetes cluster so Dex doesn't need to worry about the authenticating proxy in front of the public URLs. Dex logs the following error upon attempted login:
Even if we were to self-sign certificates for in-cluster hostnames, we wouldn't be able to use the
rootCAs
option to make the verifier respect that either.What this PR does / why we need it
Special notes for your reviewer
This PR closely follows prior art from #2781.
It doesn't appear that there's a great way to test this sort of TLS behavior here; #2781 didn't include tests either. We're currently running this patch in production and it's solved the issue. I suppose it'd be possible to reach into the JWT verifier with reflection to check that the ctx has the expected value set... but that seems brittle to me. Happy for suggestions.