Scope ssh jwt cache by credential - #48
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR scopes the on-disk SSH JWT/proxy cache by the resolved auth credential to prevent cross-credential cache collisions (e.g., one ssh sign overwriting the token/proxy address another connection is about to use).
Changes:
- Added
auth.Session.CacheIdentity()to derive a stable, filesystem-safe cache scope for the resolved credential. - Updated SSH
sign/proxyflow to read/write cache entries under.jwt-cache/<cacheIdentity>/.... - Added unit and command-level tests to verify cache isolation across credentials and stability/non-leakage of
CacheIdentity.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/ssh/ssh.go | Nests JWT cache paths under a per-credential cacheIdentity directory and updates save/load helpers. |
| internal/ssh/ssh_test.go | Expands tests to validate cache directory perms and isolation across different cache identities. |
| internal/ssh/connect.go | Threads cacheIdentity through Sign/Proxy and scopes cache read/write to that identity. |
| internal/cmd/command.ssh.go | Resolves cacheIdentity from the current session and passes it into SSH sign/proxy commands. |
| internal/cmd/command.ssh_test.go | Adds an integration-style test ensuring proxy does not read cache written under a different credential. |
| internal/auth/transport.go | Introduces Session.CacheIdentity() using hashed identifiers for profile- and key-based sessions. |
| internal/auth/transport_test.go | Adds tests ensuring CacheIdentity is stable, scoped, and does not leak raw profile name or key. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cretz
marked this pull request as ready for review
August 5, 2026 17:45
| func saveJWT(d string, h hostname, jwt, proxyAddr string) error { | ||
| if err := os.MkdirAll(filepath.Join(d, ".jwt-cache"), 0o700); err != nil { | ||
| func saveJWT(d, cacheIdentity string, h hostname, jwt, proxyAddr string) error { | ||
| if err := os.MkdirAll(filepath.Join(d, ".jwt-cache", cacheIdentity), 0o700); err != nil { |
There was a problem hiding this comment.
Literal jwt-cache appears in two places, can you instread use soemthing lieke
file = jwtCachePath(...)
os.MkdirAll(Dir(file))
Collaborator
Author
There was a problem hiding this comment.
The two places building this dir probably not worth a new one-line method, not much logic here
marius-baseten
approved these changes
Aug 5, 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.
🚀 What
signunder one credential can't overwrite the token and proxy address another connection is about to read.💻 How
auth.Session.CacheIdentity():profile-<hash>,key-<hash>, oranonymous. Hashed to keep the profile name (an email by default) and the API key out of file paths.sign/proxypass it through, nesting entries under.jwt-cache/<identity>/.signruns before every connection, so nothing breaks.🔬 Testing
proxyrejects an entry written under a different credential, andCacheIdentityis stable and leaks neither name nor key.go test ./internal/ssh/... ./internal/auth/... ./internal/cmd/...