mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
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:
1 parent
5b85abd627
commit
55af93062a
31 files changed
+1136
-132
No files matched your search
@@ -112,6 +112,36 @@ export function findGitHubCredential(credentials: GitCredential[]): GitCredentia
|
||||
}) || null
|
||||
}
|
||||
|
||||
export function createGhCliEnv(credentials: GitCredential[]): Record<string, string> {
|
||||
const githubCred = findGitHubCredential(credentials)
|
||||
if (!githubCred?.token) return {}
|
||||
return { GH_TOKEN: githubCred.token, GITHUB_TOKEN: githubCred.token }
|
||||
}
|
||||
|
||||
export interface ResolvedGitCredential {
|
||||
username: string
|
||||
password: string
|
||||
}
|
||||
|
||||
export function findPatCredentialForHost(
|
||||
credentials: GitCredential[],
|
||||
hostname: string
|
||||
): ResolvedGitCredential | null {
|
||||
const target = normalizeGitCredentialUrl(hostname)?.hostname.toLowerCase()
|
||||
if (!target) return null
|
||||
for (const cred of credentials) {
|
||||
if (cred.type && cred.type !== 'pat') continue
|
||||
const credHost = normalizeGitCredentialUrl(cred.host)?.hostname.toLowerCase()
|
||||
if (credHost && credHost === target) {
|
||||
return {
|
||||
username: cred.username || getDefaultUsername(cred.host),
|
||||
password: cred.token || '',
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export function getSSHCredentialsForHost(credentials: GitCredential[], host: string): GitCredential[] {
|
||||
return credentials.filter(cred => {
|
||||
if (cred.type !== 'ssh') return false
|
||||
|
||||
Reference in new issue
Block a user