-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Goal: Add SSH key authentication for cloning, fetching, and pushing to repositories.
1. Backend Changes
- SSH Key Storage:
- Extend the
GitCredentialschema to support SSH keys:- Add a
typefield ("pat"or"ssh"). - Add an
sshKeyfield for the private key content (encrypted at rest). - Add a
passphrasefield for encrypted keys (optional).
- Add a
- Store keys in the existing
settings.gitCredentialsarray.
- Extend the
- Git Environment Setup:
- Extend
createGitEnvingit-auth.tsto:- Detect SSH URLs (e.g.,
git@github.com:user/repo.git). - Write the SSH key to a temporary file in the container (e.g.,
/tmp/ssh_keys/{repoId}). - Set
GIT_SSH_COMMANDto use the key:ssh -i /tmp/ssh_keys/{repoId} -o IdentitiesOnly=yes.
- Detect SSH URLs (e.g.,
- Handle key permissions (e.g.,
chmod 600for the key file).
- Extend
- Key Validation:
- Validate SSH keys on save (e.g., check for
-----BEGIN OPENSSH PRIVATE KEY-----). - Reject invalid keys with a clear error message.
- Validate SSH keys on save (e.g., check for
2. Frontend UX
- Git Credentials UI:
- Add a toggle in the Git Credentials panel [1] to switch between PAT and SSH key.
- For SSH keys:
- Add a textarea for pasting the private key.
- Add an optional passphrase field.
- Add a "Test SSH Connection" button to verify the key works.
- Show a warning: "Never share your private key. It will be encrypted at rest."
- Repository Cloning:
- Auto-detect SSH URLs (e.g.,
git@github.com:user/repo.git) and prompt for the SSH key if not configured. - Show a tooltip: "This repo requires SSH authentication. Add your key in Settings > Git Credentials."
- Auto-detect SSH URLs (e.g.,
- Error Handling:
- Show clear errors for SSH failures (e.g., "Permission denied (publickey)").
- Suggest fixes (e.g., "Check your key or add it to your GitHub account.").
3. Security
- Key Encryption:
- Encrypt SSH keys at rest using a symmetric key derived from the user’s session (e.g., via
crypto.subtle). - Never log or expose keys in plaintext.
- Use
fs.unlinkSyncin afinallyblock.
- Encrypt SSH keys at rest using a symmetric key derived from the user’s session (e.g., via
Metadata
Metadata
Assignees
Labels
No labels
Projects
Status
No status