Skip to content

Add explicit Git credentials for private remotes - #13

Merged
gmpassos merged 1 commit into
masterfrom
feat/git-drive-credentials
Jul 1, 2026
Merged

Add explicit Git credentials for private remotes#13
gmpassos merged 1 commit into
masterfrom
feat/git-drive-credentials

Conversation

@gmpassos

@gmpassos gmpassos commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Context

Git drives previously had no credential model — GitCli shelled out to git with just a URL, relying on whatever the host git install could authenticate with. That fails on fresh CI runners, containers, and any headless endpoint cloning/fetching/pushing a private repo.

This adds first-class Git credentials so an endpoint can authenticate to private remotes over HTTPS (PAT or username+password) and SSH (private key).

Design

  • GitCredential sealed value object with three variants — GitPat, GitUserPass, GitSshKey. Each injects itself at the single GitCli process chokepoint: HTTPS via -c http.extraHeader=Authorization: Basic <b64>, SSH via GIT_SSH_COMMAND=ssh -i <key>. Secrets are masked in toString() (mirrors AuthToken).
  • GIT_TERMINAL_PROMPT=0 is always set, so a missing/wrong credential fails fast instead of hanging on an interactive prompt.
  • Host-scoped storage. Credentials live only in a local credentials.json (keyed by git host, tightened to 0600) and are resolved by the origin's host at invocation time via a GitCredentialResolver. They are never placed on the Drive entity, so they never reach drives.json, the hub registry, or peer HTTP payloads.
  • CLI: omnydrive credential add <host> (--pat | --username/--password | --ssh-key), credential list (masked), credential remove <host>. publish/clone/sync resolve the matching credential automatically by host — no new per-command flags.

Passphrase-protected SSH keys still require an ssh-agent (documented limitation; passphrase is retained for a future SSH_ASKPASS upgrade).

Tests

  • New unit tests for GitCredential (basic-auth header encoding, GIT_SSH_COMMAND, masking, JSON round-trip), GitCredentialStore (put/get/remove/resolve + save→load), and OriginUri.host extraction.
  • Existing git integration tests use local-path origins with no resolver → credential is null, behavior unchanged.
  • dart analyze clean; full suite (234 tests) green.
  • Manual (real remotes, not CI): real auth can't be exercised against a local path — verify by adding a PAT/SSH key and cloning a private repo, confirming the token lands in credentials.json but not drives.json/hub payloads.

Bumps version to 1.9.0.

🤖 Generated with Claude Code

Git drives previously relied entirely on the host git installation to
authenticate, which fails on headless/CI endpoints cloning private repos.

Add a GitCredential value object (HTTPS PAT, username+password, SSH key)
that injects itself at the single GitCli process chokepoint — HTTPS via
`-c http.extraHeader` basic auth, SSH via GIT_SSH_COMMAND — and always
sets GIT_TERMINAL_PROMPT=0 so a missing/wrong credential fails fast.

Credentials are host-scoped and stored only in a local credentials.json
(0600), resolved by the origin's host via GitCredentialResolver. They are
never placed on the Drive entity, so they never reach drives.json, the hub,
or peers. Manage them with `omnydrive credential add/list/remove`; publish,
clone, and sync resolve the matching credential automatically by host.

Bumps version to 1.9.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gmpassos
gmpassos merged commit 81d2f54 into master Jul 1, 2026
2 checks passed
@gmpassos
gmpassos deleted the feat/git-drive-credentials branch July 1, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant