Repository navigation
feat(git): per-host HTTPS Git credentials for workspace agents - #1015
Conversation
Users keep one HTTPS access token per Git host. Workspace turns fetch the token for a host on demand through the session gateway (git credential helper, gh/glab shims) instead of receiving it in the environment. Tokens the agent writes into the workspace are scrubbed after each CLI turn and redacted from replies and diagnostics. PRs and MRs opened on GitHub, GitHub Enterprise and GitLab are registered as requirement deliveries and polled with the registering user's credential.
The new Git access token form labelled its token field "访问令牌" and added an English translation for it. i18n translates exact text nodes, so the GitHub credential wizard's "访问令牌" tab became "Access token" in English too, which broke the onboarding journey that opens that tab. Label the new field "个人访问令牌" (matching its placeholder) and translate that instead. Co-Authored-By: Claude Code <noreply@anthropic.com>
CI fix:
|
| Wizard token tab (EN) | Add token form (EN) | Saved list (EN) | Add token form (ZH) |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
The four new /api/users/:id/git-http-credentials routes had no e2e request, which dropped the browser job's route coverage to 84.7% (gate 85%). Exercise save, replace, list without the token, validation, the missing-credential verify path, the second user's 403 and delete. Co-Authored-By: Claude Code <noreply@anthropic.com>
Follow-up:
|
Replace scalar token reads with host-scoped Git helpers across the platform, runners and terminals. Let the first Agent recover failed repository preparation, validate the frozen checkout, preserve explicit SSH transport, and accept generic HTTPS Git URLs without a hosting adapter. Remove the workspace exposure toggle, migrate historical personal tokens with manual SQL, and redact credentials across streamed model deltas.
Refresh the GitHub credential flag when the host list changes, translate repository token guidance, and verify the generic credential dialog from repository setup on desktop and mobile.
Mount the shared selector panel in its native dialog so its options receive clicks and keyboard focus. Clarify that agents can create PRs on other hosts, and that the platform's merge reporting needs a supported hosting integration.
|
[P2] 校验检出包含已有远端工作分支的提交 本地 Git 复验中, 当前提交的 Git 凭据、工作区及交付 Go 回归已通过。相关代码 |
|
[P2] 校验兜底新建的工作分支包含冻结基线 已复验已有远端工作分支的修复。首次建工作分支时仍会放行错误的起点。用本地 Git 让 |
Robert0622
left a comment
There was a problem hiding this comment.
本地复测发现一处终端凭证归属问题,已标在代码行。
| request.TerminalGitSSHKeys = nil | ||
| terminalOpen := request.Operation == domain.RunnerWorkspaceOperationTerminal && request.Terminal != nil && request.Terminal.Operation == "open" | ||
| if runnerID != "" && (request.Operation == domain.RunnerWorkspaceOperationPrepare || terminalOpen) { | ||
| invocation.GitHTTPCredentials = credentials.GitHTTPCredentials |
There was a problem hiding this comment.
[P1] 交互终端应使用打开终端的用户自己的 Git 凭证
这里把 SOP 责任人的全部 HTTPS Git 凭证放入 PreparationInvocation,Runner 随后用同一份凭证配置交互终端。项目成员打开终端时可以使用另一位用户的凭证,范围还包括当前 SOP 未绑定的 Git 主机。本地用两个测试账号和一个无仓库 SOP 复现了错误的凭证下发。请把准备阶段和终端的凭证分开,终端按 TerminalOwner 解析,与 SSH 路径一致。
Robert0622
left a comment
There was a problem hiding this comment.
复测通过。SOP 准备和交互终端分别选择了对应账号的 Git 凭证。用两个账号和无凭证终端验证了隔离,Runner 和实际 PTY 的专项回归也通过。
Robert0622
left a comment
There was a problem hiding this comment.
复审了合入 main 的这次提交。终端继续按打开终端的用户绑定 Git 凭证,SOP 准备仍按运行责任人解析。凭证隔离、实际 PTY(含 Docker)、Runner、Git 凭证中继以及 MCP 和工作区准备专项回归均通过。




Git authentication now resolves the responsible user's credential for the exact HTTPS host throughout workspace agents, SOP checkout and branch preparation, runner execution, terminals, and GitHub delivery polling. Saving a new host credential no longer leaves the platform reading an obsolete scalar token.
Deployments must manually run
migrations/036_git_http_credentials.sqlfollowed bymigrations/037_retire_plain_git_token.sql. These migrate historical personal GitHub tokens, retire the old scalar value and remove the exposure column. Managed deployment OAuth remains isolated in its adapter; execution does not dual-read personal tokens.Validation: real CodeBuddy iOA/hy4 runs against personal private GitHub and CNB repositories completed clone, frozen branch preparation, commit, push and Agent-created PRs. Native and Docker SOP delivery passed, as did an injected platform-clone failure recovered by the first Agent and verified by a downstream node. Disposable PRs and branches were cleaned up; both remote main branches remained unchanged. The SQL migration was rerun locally against Docker MySQL to check idempotence. Platform web tests passed 207/207 with 87.7% line coverage (85% gate); chatbot tests/build and focused Git helper, runner claim, streamed-redaction and cancellation regressions passed. GitHub CI is tracked on the pushed head commit.