Skip to content

feat: store tokens in git credential manager instead of plaintext#138

Merged
rhuanbarreto merged 1 commit into
mainfrom
feat/git-credential-storage
Mar 22, 2026
Merged

feat: store tokens in git credential manager instead of plaintext#138
rhuanbarreto merged 1 commit into
mainfrom
feat/git-credential-storage

Conversation

@rhuanbarreto

Copy link
Copy Markdown
Contributor

Summary

  • Store archgate tokens in the OS credential manager (macOS Keychain, Windows Credential Manager, Linux libsecret) using git's native git credential approve/fill/reject protocol
  • Transparent git authentication — after archgate login, git clone https://plugins.archgate.dev/archgate.git works automatically (git retrieves stored credentials from its own credential helper)
  • No custom credential helper needed — leverages the user's already-configured credential.helper (GCM, osxkeychain, libsecret, etc.)

How it works

Storage

What Before After
Token Plaintext JSON in ~/.archgate/credentials OS credential manager (encrypted at rest)
Metadata Same file Same file (github_user, created_at only)

Git authentication flow

```

  1. archgate login → claims token → git credential approve (stores in OS keychain)
  2. git clone https://plugins.archgate.dev/archgate.git
  3. git calls its configured credential helper (e.g., osxkeychain)
  4. Credential helper returns username + token for plugins.archgate.dev
  5. git sends Basic Auth header → backend validates token (BE-002, unchanged)
    ```

Backwards compatibility

  • Existing plaintext ~/.archgate/credentials files still work (fallback)
  • URLs with embedded credentials (user:token@host) still work
  • No backend changes required

Files changed

  • New: `src/helpers/credential-store.ts` — git credential protocol wrapper
  • Modified: `src/helpers/auth.ts` — re-exports from credential-store.ts

Test plan

  • All 57 affected tests pass, 0 failures
  • Lint passes (0 errors)
  • Typecheck clean (only pre-existing sentry/telemetry issues)
  • End-to-end: `archgate login` stores token in OS keychain
  • End-to-end: `git clone https://plugins.archgate.dev/archgate.git\` authenticates automatically
  • Verify fallback works for legacy plaintext credentials
  • Test on macOS (Keychain), Windows (Credential Manager), Linux (libsecret)

🤖 Generated with Claude Code

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 22, 2026

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: a30c39e
Status: ✅  Deploy successful!
Preview URL: https://a01010ea.archgate-cli.pages.dev
Branch Preview URL: https://feat-git-credential-storage.archgate-cli.pages.dev

View logs

@rhuanbarreto rhuanbarreto force-pushed the feat/git-credential-storage branch 4 times, most recently from 79ba887 to 654d1dc Compare March 22, 2026 19:31
Replace plaintext token storage in ~/.archgate/credentials with git's
native credential helpers (macOS Keychain, Windows Credential Manager,
Linux libsecret) via the `git credential approve/fill/reject` protocol.

This means git clone from plugins.archgate.dev works transparently —
git retrieves stored credentials automatically without tokens in URLs.

Changes:
- New credential-store.ts using git credential approve/fill/reject
- auth.ts no longer re-exports — consumers import directly from
  credential-store.ts (ARCH-004 compliance)
- ~/.archgate/credentials kept for metadata (github_user, created_at)
- Falls back to plaintext file for legacy installs
- GIT_TERMINAL_PROMPT=0 + GCM_INTERACTIVE=never suppress all prompts
- 3-second timeout prevents hangs when credential manager is unavailable
- ARCH-004 updated to also prohibit re-exports from non-index files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rhuanbarreto rhuanbarreto force-pushed the feat/git-credential-storage branch from 654d1dc to a30c39e Compare March 22, 2026 19:47
@rhuanbarreto rhuanbarreto merged commit e495e01 into main Mar 22, 2026
8 checks passed
@rhuanbarreto rhuanbarreto deleted the feat/git-credential-storage branch March 22, 2026 19:58
@github-actions github-actions Bot mentioned this pull request Mar 22, 2026
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