feat: SSH Authentication Keys v2 (#113)

* feat: add SSH authentication keys v2 for Git operations

Add comprehensive SSH key authentication support for Git operations including:
- SSH host key verification with user approval flow
- Encrypted SSH key storage with passphrase support
- SSH connection testing endpoint
- Real-time host key change warnings

Backend changes:
- New SSHHostKeyHandler for managing host key verification via IPC
- Add passphrase handler for locked SSH keys
- Add SSH key manager utilities (key writing, validation, cleanup)
- Add crypto utilities for secure key/secret encryption
- Add SSH validation utilities for key format checking
- Add SSH routes for host key response handling
- Enhance GitAuthService with SSH setup and environment methods
- Update GitService to handle SSH authentication for push/fetch/pull
- Update OpenCode server to support SSH keys with SSH config generation
- Add database migration for trusted_ssh_hosts table
- Add settings endpoint for SSH connection testing

Frontend changes:
- Add SSHHostKeyDialog for host key verification UI
- Add PassphraseModal for SSH key passphrase input
- Update GitCredentialDialog with SSH key type and testing
- Update GitSettings to manage SSH keys
- Add SSH API client and hooks (useSSH, usePassphraseHandler)

Shared changes:
- Add SSH schemas and types

Test coverage:
- Integration tests for SSH flow
- IPC handler tests for host key and passphrase
- SSH route tests
- SSH utility validation tests
- Updated existing tests for SSH-aware changes
This commit is contained in:
Chris Scott authored and GitHub committed 2026-02-08 00:06:44 -05:00
1 parent 3d5ee463d7
commit 414f39b809
54 files changed
+4051 -214

No files matched your search

@@ -41,7 +41,10 @@ export function SettingsDialog() {
useEffect(() => {
if (!isOpen) return
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape') close()
if (e.key === 'Escape') {
e.stopPropagation()
close()
}
}
document.addEventListener('keydown', handleKeyDown)
return () => document.removeEventListener('keydown', handleKeyDown)
@@ -116,14 +119,14 @@ export function SettingsDialog() {
<div className="flex-1 overflow-y-auto">
<div className="px-6 pb-6">
<TabsContent value="account" className="mt-0"><AccountSettings /></TabsContent>
<TabsContent value="general" className="mt-0"><GeneralSettings /></TabsContent>
<TabsContent value="notifications" className="mt-0"><NotificationSettings /></TabsContent>
<TabsContent value="voice" className="mt-0"><VoiceSettings /></TabsContent>
<TabsContent value="git" className="mt-0"><GitSettings /></TabsContent>
<TabsContent value="shortcuts" className="mt-0"><KeyboardShortcuts /></TabsContent>
<TabsContent value="opencode" className="mt-0"><OpenCodeConfigManager /></TabsContent>
<TabsContent value="providers" className="mt-0"><ProviderSettings /></TabsContent>
<TabsContent key="account" value="account" className="mt-0"><AccountSettings /></TabsContent>
<TabsContent key="general" value="general" className="mt-0"><GeneralSettings /></TabsContent>
<TabsContent key="notifications" value="notifications" className="mt-0"><NotificationSettings /></TabsContent>
<TabsContent key="voice" value="voice" className="mt-0"><VoiceSettings /></TabsContent>
<TabsContent key="git" value="git" className="mt-0"><GitSettings /></TabsContent>
<TabsContent key="shortcuts" value="shortcuts" className="mt-0"><KeyboardShortcuts /></TabsContent>
<TabsContent key="opencode" value="opencode" className="mt-0"><OpenCodeConfigManager /></TabsContent>
<TabsContent key="providers" value="providers" className="mt-0"><ProviderSettings /></TabsContent>
</div>
</div>
</Tabs>
@@ -156,41 +159,41 @@ export function SettingsDialog() {
</Button>
</div>
<div className="flex-1 min-h-0 overflow-y-auto p-4 pb-32">
{mobileView === 'menu' && (
<div className="space-y-3">
{menuItems.map((item) => (
<button
key={item.id}
onClick={() => {
setMobileView(item.id as SettingsView)
setActiveTab(item.id as SettingsView)
}}
className="w-full bg-gradient-to-br from-card to-card-hover border border-border rounded-xl p-4 hover:border-border transition-all duration-200 text-left"
>
<div className="flex items-center gap-4">
<div className="p-3 bg-accent rounded-lg">
<item.icon className="w-6 h-6 text-blue-600 dark:text-blue-400" />
</div>
<div className="flex-1 min-w-0">
<h3 className="font-semibold text-foreground mb-1">{item.label}</h3>
<p className="text-sm text-muted-foreground">{item.description}</p>
</div>
</div>
</button>
))}
</div>
)}
<div className="flex-1 min-h-0 overflow-y-auto p-4 pb-32">
{mobileView === 'menu' && (
<div className="space-y-3">
{menuItems.map((item) => (
<button
key={item.id}
onClick={() => {
setMobileView(item.id as SettingsView)
setActiveTab(item.id as SettingsView)
}}
className="w-full bg-gradient-to-br from-card to-card-hover border border-border rounded-xl p-4 hover:border-border transition-all duration-200 text-left"
>
<div className="flex items-center gap-4">
<div className="p-3 bg-accent rounded-lg">
<item.icon className="w-6 h-6 text-blue-600 dark:text-blue-400" />
</div>
<div className="flex-1 min-w-0">
<h3 className="font-semibold text-foreground mb-1">{item.label}</h3>
<p className="text-sm text-muted-foreground">{item.description}</p>
</div>
</div>
</button>
))}
</div>
)}
{mobileView === 'account' && <AccountSettings />}
{mobileView === 'general' && <GeneralSettings />}
{mobileView === 'notifications' && <NotificationSettings />}
{mobileView === 'voice' && <VoiceSettings />}
{mobileView === 'git' && <GitSettings />}
{mobileView === 'shortcuts' && <KeyboardShortcuts />}
{mobileView === 'opencode' && <OpenCodeConfigManager />}
{mobileView === 'providers' && <ProviderSettings />}
</div>
{mobileView === 'account' && <div key="account"><AccountSettings /></div>}
{mobileView === 'general' && <div key="general"><GeneralSettings /></div>}
{mobileView === 'notifications' && <div key="notifications"><NotificationSettings /></div>}
{mobileView === 'voice' && <div key="voice"><VoiceSettings /></div>}
{mobileView === 'git' && <div key="git"><GitSettings /></div>}
{mobileView === 'shortcuts' && <div key="shortcuts"><KeyboardShortcuts /></div>}
{mobileView === 'opencode' && <div key="opencode"><OpenCodeConfigManager /></div>}
{mobileView === 'providers' && <div key="providers"><ProviderSettings /></div>}
</div>
</div>
</DialogContent>
</Dialog>