Repository navigation
Add TLS to Redis session storage - #6731
Merged
Merged
Conversation
Signed-off-by: Sanskarzz <[email protected]>
Sanskarzz
requested review from
ChrisJBurns,
JAORMX,
amirejaz,
aponcedeleonch,
blkt,
jerm-dro,
jhrozek,
rdimitrov,
reyortiz3 and
tgrunnagle
as code owners
September 30, 2026 14:29
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6731 +/- ##
=======================================
Coverage 79.28% 79.28%
=======================================
Files 802 804 +2
Lines 81218 81271 +53
=======================================
+ Hits 64395 64439 +44
- Misses 16818 16827 +9
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
peppescg
approved these changes
Oct 9, 2026
peppescg
left a comment
Contributor
There was a problem hiding this comment.
Thanks a lot @Sanskarzz, this is a really solid piece of work! 🙌
This was referenced Oct 9, 2026
peppescg
added a commit
that referenced
this pull request
Oct 12, 2026
* Move Redis TLS test fixture to testkit Shared test fixtures live under test/testkit. Move the redistls helper added for Redis session storage TLS there and update its importers; the fixture itself is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Giuseppe Scuglia <[email protected]> * Warn when Redis session storage lacks TLS Session storage now supports TLS, but omitting it keeps the previous plaintext connection so existing deployments are unaffected. Make that choice visible: when a Redis password is configured, the proxy runner and vMCP session stores log one startup WARN if TLS is not set or certificate verification is disabled. The connection is still allowed and the password is never logged. The message also notes that the operator-wide default Redis (TOOLHIVE_DEFAULT_REDIS_ADDR) cannot enable TLS yet. The rate limiter always shares these settings, so it does not warn again. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Giuseppe Scuglia <[email protected]> * Add session storage TLS to the operator #6731 lets the proxy runner and vMCP connect to Redis session storage over TLS, but only through hand-written RunConfig or vMCP YAML. Operator-managed workloads had no way to request it. Add spec.sessionStorage.tls to MCPServer, MCPRemoteProxy and VirtualMCPServer. It reuses the existing RedisTLSConfig type from the embedded auth server's Redis storage: - An empty object verifies the server certificate against the system roots. - caCertSecretRef mounts a private CA from a Secret at /etc/toolhive/session-redis-tls/ca.crt, read-only and via subPath, as for the auth server's Redis CA. - insecureSkipVerify disables verification, for testing only. The operator writes these settings into the RunConfig (scaling_config.session_redis.tls) and the vMCP config (sessionStorage.tls). On VirtualMCPServer the operator value replaces any spec.config.sessionStorage.tls, like the other session storage fields. Switching the referenced CA Secret rolls the Deployment. CEL rules on SessionStorageConfig reject tls with a non-redis provider, and insecureSkipVerify combined with caCertSecretRef. They sit on SessionStorageConfig rather than on the shared type so existing auth server resources are unaffected. The shared insecureSkipVerify description now recommends caCertSecretRef instead. Refs #6730 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Giuseppe Scuglia <[email protected]> * Extend Redis session storage TLS tests Add coverage for the Redis session storage TLS paths that were not exercised end to end: - Runner.Run test showing the session store client takes its TLS settings from the RunConfig. Without TLS it does not handshake. With TLS, the server certificate and the hostname from the configured address are verified. A trusted CA connects. - The rate limiter and the vMCP limiter factory now also cover the omitted-TLS case against a TLS-only server, and match the certificate-verification error precisely. - An e2e spec that runs standalone vMCP against a TLS-only, password-protected Redis container. It opens a session and checks over TLS that the session was stored. The redistls fixture gains on-disk certificates with an IP-only server certificate. A real Redis server uses them, and they make a hostname mismatch observable. Refs #6730 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Giuseppe Scuglia <[email protected]> * Make e2e Redis TLS certificates readable The TLS-only Redis e2e spec bind-mounts a generated CA, certificate and key into the Redis container. Only the key was made world-readable, so on Linux hosts, where the container's redis user does not own the mounted files, Redis could not read the 0600 certificate and CA, failed to configure TLS and exited before answering PING. Docker Desktop on macOS does not enforce file ownership on bind mounts, which hid this locally. Make all three files readable inside the private test directory. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Giuseppe Scuglia <[email protected]> * Address review findings on session Redis TLS The session storage CA drift check compared the live Deployment with the raw desired volume. On an MCPRemoteProxy whose podTemplateSpec patches that volume, every reconcile saw drift and issued a no-op update. The check now compares live volumes with the desired ones, and the remote proxy uses the rebuilt, patched Deployment when a podTemplateSpec is set. Reject configurations that would silently misbehave: - spec.config.sessionStorage.tls on a VirtualMCPServer was accepted but discarded by the converter, leaving the connection plaintext. - A caCertSecretRef with an empty name or key passed admission but produced a volume the Deployment API rejects on every reconcile. The insecure-transport warning moves into the Redis session store constructors so every caller gets it, and it now also fires without a password because session data still crosses the network in plaintext. Its text no longer names configuration keys that only apply to some callers. Also share one Secret-file volume helper between the session store and the embedded auth server's Redis CAs, build the redistls fixture on a single certificate generator, and drop a runner test case that only exercised crypto/tls and go-redis. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Giuseppe Scuglia <[email protected]> * Set fosite strategies that default lazily fosite's GetAudienceStrategy and GetJWKSFetcherStrategy assign their default to the shared Config on first use. The embedded auth server left both unset, so concurrent token requests raced on that write. The race detector flagged it in the pkg/authserver integration tests, which fail on main as well. Set both to fosite's defaults when building the Config, as is already done for the scope strategy and secrets hasher. Behavior is unchanged; the getters simply no longer write. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Giuseppe Scuglia <[email protected]> * Fail closed on remote client key sets The previous commit set fosite's JWKS fetcher to its default to avoid a lazy write to the shared Config. That fetcher is never used: DCR rejects jwks_uri for private_key_jwt and storage drops it, so client keys are always inline. Creating it eagerly only started a ristretto cache with goroutines that are never closed, for every auth server instance. Use a fetcher that rejects the client instead. It still keeps fosite's getter from writing, starts nothing, and fails closed rather than fetching an arbitrary URL with an unhardened client if a client with a jwks_uri ever reached client authentication. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Giuseppe Scuglia <[email protected]> * Check session TLS rules on every kind and version The sessionStorage.tls CEL rules live on the shared SessionStorageConfig type, but admission tests only covered VirtualMCPServer at v1beta1. A schema change could drop a rule from one kind or one served version without any test noticing. Run one shared table of TLS admission cases against MCPServer, MCPRemoteProxy and VirtualMCPServer at both v1beta1 and v1alpha1. Also document that workloads using the operator-wide defaultRedis fallback always log the plaintext warning, and that vMCP's no-authentication warning is separate from it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Giuseppe Scuglia <[email protected]> --------- Signed-off-by: Giuseppe Scuglia <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
1 task
This was referenced Oct 14, 2026
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.
Summary
Redis session storage configuration currently cannot enable TLS, even though the shared
redisconnlibrary supports it. This prevents standalone vMCP and proxy runtimes from connecting to Redis endpoints that require TLS. Redis-backed rate limiting creates a separate client and needs the same settings.tlsis omitted;tls: {}enables certificate and hostname verification using system roots.redisconn.NewClientfor the rate limiter and share CA loading with the embedded auth server while preserving its existing snake_case configuration.Partially addresses #6730. This is the runtime prerequisite; the Kubernetes API fields, CA Secret projection, and rollout handling will follow in PR B. Keep the issue open until that integration is merged.
TLS support for the operator-wide
defaultRedisfallback is outside the scope of both PR A and PR B and will be tracked in a separate follow-up issue.Type of change
Test plan
task sdk-test).task lint-fix, previously run on the complete implementation).task operator-manifests,task crdref-gen --force) against PR A alone and compare with the staged artifacts.task test-e2e).Coverage includes:
The full repository unit run previously hit a failure in
TestPush/key_push_forwards_signing_capabilityin the plugin client package; that package passed on an isolated rerun. The full repository suite is not claimed as green here. Runner coverage does not execute the fullRunner.Runlifecycle against TLS Redis, and no live Kubernetes workload connection is included in this PR.API Compatibility
v1beta1API.The optional nested
VirtualMCPServer.spec.config.sessionStorage.tlsschema additions are generated from the embedded runtime configuration, in both served versions. They keep generated artifacts aligned with the runtime type; top-levelspec.sessionStorage.tlsand Secret references belong to PR B. Existing omitted TLS settings preserve plaintext behavior.Changes
pkg/redisconfig/tls.gopkg/authserver/runner/embeddedauthserver.gopkg/vmcp/config/config.go,validator.gopkg/vmcp/server/server.gopkg/runner/config.go,runner.go,middleware.gopkg/ratelimit/middleware.gopkg/vmcp/ratelimit/factory/limiter.gotest/helpers/redistls/redistls.gocmd/vmcp/README.mddocs/server/*,sdk/go/openapi.*,sdk/go/client/oas_*_gen.go,sdk/go/client/client_test.goDoes this introduce a user-facing change?
Yes. Standalone
thv vmcp serve --config ...andvmcp serve --config ...accept:For a private CA, set
tls.caCertFileto a readable PEM bundle in the runtime filesystem. Proxy run configurations receive the same optional TLS object under their existing session Redis settings. No new CLI flag is introduced.Implementation plan
Implementation plan
Special notes for reviewers
insecureSkipVerifyis an explicit opt-in that disables certificate and hostname verification.defaultRedisfallback is a separate follow-up.