refactor: extract CredentialProvider service and consolidate git-auth utilities (#283)

* refactor: extract CredentialProvider service and consolidate git-auth utilities

* refactor: add git-credentials route and gh env plugin, pass internal token to OpenCode

* refactor: update credential provider integration and git route

* refactor: integrate credential provider across git auth, routes, and IPC
This commit is contained in:
Chris Scott authored and GitHub committed 2026-06-20 21:52:18 -04:00
1 parent 5b85abd627
commit 55af93062a
31 files changed
+1136 -132

No files matched your search

+6 -7
View File
@@ -4,10 +4,10 @@ import { AskpassHandler } from '../ipc/askpassHandler'
import { SSHHostKeyHandler } from '../ipc/sshHostKeyHandler'
import { writeTemporarySSHKey, buildSSHCommand, buildSSHCommandWithKnownHosts, cleanupSSHKey, parseSSHHost } from '../utils/ssh-key-manager'
import { decryptSecret } from '../utils/crypto'
import { isSSHUrl, normalizeSSHUrl, extractHostFromSSHUrl, getSSHCredentialsForHost } from '../utils/git-auth'
import { isSSHUrl, normalizeSSHUrl, extractHostFromSSHUrl } from '../utils/git-auth'
import type { GitCredential } from '@opencode-manager/shared'
import { logger } from '../utils/logger'
import { SettingsService } from './settings'
import { CredentialProvider } from './credential-provider'
export class GitAuthService {
private askpassHandler: AskpassHandler | null = null
@@ -15,9 +15,11 @@ export class GitAuthService {
private sshKeyPath: string | null = null
private sshPassphrase: string | null = null
private sshPort: string | null = null
private credentialProvider: CredentialProvider | null = null
async initialize(ipcServer: IPCServer | undefined, database: Database): Promise<void> {
this.askpassHandler = new AskpassHandler(ipcServer, database)
this.credentialProvider = new CredentialProvider(database)
this.askpassHandler = new AskpassHandler(ipcServer, this.credentialProvider)
this.sshHostKeyHandler = new SSHHostKeyHandler(database, 120_000)
await this.sshHostKeyHandler.initialize()
@@ -97,10 +99,7 @@ export class GitAuthService {
const { port } = parseSSHHost(normalizedUrl)
this.setSSHPort(port && port !== '22' ? port : null)
const settingsService = new SettingsService(database)
const settings = settingsService.getSettings('default')
const gitCredentials = (settings.preferences.gitCredentials || []) as GitCredential[]
const sshCredentials = getSSHCredentialsForHost(gitCredentials, sshHost)
const sshCredentials = this.credentialProvider!.getSshCredentialsForHost(sshHost)
if (sshCredentials.length > 0 && sshCredentials[0]) {
try {