mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
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:
1 parent
3d5ee463d7
commit
414f39b809
54 files changed
+4051
-214
No files matched your search
@@ -209,9 +209,9 @@ describe('fetchGitHubUserInfo', () => {
|
||||
describe('findGitHubCredential', () => {
|
||||
it('should find GitHub credential in credentials array', () => {
|
||||
const credentials: GitCredential[] = [
|
||||
{ name: 'gitlab', host: 'https://gitlab.com/', token: 'gitlab-token' },
|
||||
{ name: 'github', host: 'https://github.com/', token: 'github-token' },
|
||||
{ name: 'private', host: 'https://git.example.com/', token: 'private-token' },
|
||||
{ name: 'gitlab', host: 'https://gitlab.com/', type: 'pat', token: 'gitlab-token' },
|
||||
{ name: 'github', host: 'https://github.com/', type: 'pat', token: 'github-token' },
|
||||
{ name: 'private', host: 'https://git.example.com/', type: 'pat', token: 'private-token' },
|
||||
]
|
||||
|
||||
const result = findGitHubCredential(credentials)
|
||||
@@ -219,13 +219,14 @@ describe('findGitHubCredential', () => {
|
||||
expect(result).toEqual({
|
||||
name: 'github',
|
||||
host: 'https://github.com/',
|
||||
type: 'pat',
|
||||
token: 'github-token'
|
||||
})
|
||||
})
|
||||
|
||||
it('should not find GitHub credential with www subdomain', () => {
|
||||
const credentials: GitCredential[] = [
|
||||
{ name: 'github', host: 'https://www.github.com/', token: 'github-token' },
|
||||
{ name: 'github', host: 'https://www.github.com/', type: 'pat', token: 'github-token' },
|
||||
]
|
||||
|
||||
const result = findGitHubCredential(credentials)
|
||||
@@ -241,8 +242,8 @@ describe('findGitHubCredential', () => {
|
||||
|
||||
it('should return null when no GitHub credential exists', () => {
|
||||
const credentials: GitCredential[] = [
|
||||
{ name: 'gitlab', host: 'https://gitlab.com/', token: 'gitlab-token' },
|
||||
{ name: 'private', host: 'https://git.example.com/', token: 'private-token' },
|
||||
{ name: 'gitlab', host: 'https://gitlab.com/', type: 'pat', token: 'gitlab-token' },
|
||||
{ name: 'private', host: 'https://git.example.com/', type: 'pat', token: 'private-token' },
|
||||
]
|
||||
|
||||
const result = findGitHubCredential(credentials)
|
||||
@@ -273,7 +274,7 @@ describe('resolveGitIdentity', () => {
|
||||
it('should prioritize manual name but use GitHub email', async () => {
|
||||
const manual = { name: 'Custom Name', email: undefined }
|
||||
const credentials: GitCredential[] = [
|
||||
{ name: 'github', host: 'https://github.com/', token: 'gh-token' },
|
||||
{ name: 'github', host: 'https://github.com/', type: 'pat', token: 'gh-token' },
|
||||
]
|
||||
|
||||
const userResponse = {
|
||||
@@ -306,7 +307,7 @@ describe('resolveGitIdentity', () => {
|
||||
it('should use GitHub identity when no manual identity', async () => {
|
||||
const manual = undefined
|
||||
const credentials: GitCredential[] = [
|
||||
{ name: 'github', host: 'https://github.com/', token: 'gh-token' },
|
||||
{ name: 'github', host: 'https://github.com/', type: 'pat', token: 'gh-token' },
|
||||
]
|
||||
|
||||
const userResponse = {
|
||||
@@ -339,7 +340,7 @@ describe('resolveGitIdentity', () => {
|
||||
it('should use login as name when GitHub name is null', async () => {
|
||||
const manual = undefined
|
||||
const credentials: GitCredential[] = [
|
||||
{ name: 'github', host: 'https://github.com/', token: 'gh-token' },
|
||||
{ name: 'github', host: 'https://github.com/', type: 'pat', token: 'gh-token' },
|
||||
]
|
||||
|
||||
const userResponse = {
|
||||
@@ -372,7 +373,7 @@ describe('resolveGitIdentity', () => {
|
||||
it('should return partial identity when GitHub fails but manual has one field', async () => {
|
||||
const manual = { name: 'Only Name', email: undefined }
|
||||
const credentials: GitCredential[] = [
|
||||
{ name: 'github', host: 'https://github.com/', token: 'invalid-token' },
|
||||
{ name: 'github', host: 'https://github.com/', type: 'pat', token: 'invalid-token' },
|
||||
]
|
||||
|
||||
global.fetch = vi.fn() as any;
|
||||
@@ -399,7 +400,7 @@ describe('resolveGitIdentity', () => {
|
||||
it('should return null when both manual fields are empty and GitHub fails', async () => {
|
||||
const manual = { name: undefined, email: undefined }
|
||||
const credentials: GitCredential[] = [
|
||||
{ name: 'github', host: 'https://github.com/', token: 'invalid-token' },
|
||||
{ name: 'github', host: 'https://github.com/', type: 'pat', token: 'invalid-token' },
|
||||
]
|
||||
|
||||
global.fetch = vi.fn() as any;
|
||||
|
||||
Reference in new issue
Block a user