Add CABundleRef support to TokenExchangeConfig in MCPExternalAuthConfig
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2.2k
- Forks
- 300
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 184
Description
Summary
When using token exchange with a corporate IdP that uses internal/custom CA certificates, users cannot configure a CA bundle for the token exchange HTTP client. The OIDC configuration supports CABundleRef, but the TokenExchangeConfig in MCPExternalAuthConfig does not.
Problem
The token exchange HTTP client (pkg/auth/tokenexchange/exchange.go) uses only system CAs:
var defaultHTTPClient = &http.Client{
Timeout: defaultHTTPTimeout,
}
If a corporate IdP's token endpoint uses a certificate signed by an internal CA, token exchange requests will fail with TLS verification errors.
Proposed Solution
Add CABundleRef support to TokenExchangeConfig:
Files to Modify
-
CRD (
cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go):- Add
CABundleRef *CABundleSourcetoTokenExchangeConfigstruct
- Add
-
Core package (
pkg/auth/tokenexchange/middleware.go):- Add
CACertPath stringfield toConfigstruct
- Add
-
Token exchange client (
pkg/auth/tokenexchange/exchange.go):- Modify
createTokenExchangeMiddleware()to create an HTTP client with CA bundle support usingnetworking.NewHttpClientBuilder().WithCABundle()
- Modify
-
Operator utilities (
cmd/thv-operator/pkg/controllerutil/tokenexchange.go):- Resolve CA bundle path from
CABundleRef - Add validation for
CABundleRef
- Resolve CA bundle path from
-
Volume mounting (deployment controllers):
- Mount CA bundle ConfigMap as volume for token exchange
-
Runner config (
pkg/runner/options.go):- Update
WithTokenExchangeConfig()to accept CA cert path
- Update
-
Tests and documentation
Related
This is similar to the CABundleRef support added for InlineOIDCConfig and ConfigMapOIDCRef in the OIDC configuration.
Acceptance Criteria
-
TokenExchangeConfigCRD hascaBundleReffield - Token exchange HTTP client uses configured CA bundle
- Volume mounting works for CA bundle ConfigMap
- Unit tests cover CA bundle path resolution
- CRD documentation updated
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing OIDC CABundleRef support, then inspect the listed CRD, token exchange, operator utility, deployment controller, and runner configuration files. Run the relevant token exchange and controller tests before changing behavior. Done means the CRD, CA bundle resolution, client configuration, volume mounting, tests, and documentation all cover the acceptance criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- backend, devops, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100