Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7162fab
feat(git): support tokens for generic HTTP repositories
crispinhu27 Nov 24, 2026
acd9cdd
refactor(git): simplify HTTP instance authorization
crispinhu27 Nov 24, 2026
a5976a1
fix(git): address HTTP repository review regressions
crispinhu27 Nov 24, 2026
5de5ec2
test(git): isolate redirect checks from the checkout
crispinhu27 Nov 24, 2026
6e1cc30
Merge remote-tracking branch 'origin/main' into feature/generic-http-git
crispinhu27 Nov 24, 2026
15a19e6
Merge origin/main and address HTTP Git review feedback
crispinhu27 Nov 24, 2026
7f51e70
Preserve Git helpers and direct workspace HTTP commands
crispinhu27 Nov 24, 2026
72709d1
Keep workspace Git helpers under Runner control
crispinhu27 Nov 24, 2026
59b3e02
Preserve Docker workspace state when enabling Git helpers
crispinhu27 Nov 24, 2026
69d6199
Revert "Preserve Docker workspace state when enabling Git helpers"
crispinhu27 Nov 24, 2026
6c76e71
Mount Git helpers when creating Docker workspaces
crispinhu27 Nov 24, 2026
31bb14b
Merge origin/main into generic HTTP Git branch
crispinhu27 Nov 24, 2026
edcf507
Refresh legacy Docker Git mounts during idle workspace preparation
crispinhu27 Nov 24, 2026
fafdb4f
Fix HTTP repository verification and scripts on Docker images without…
crispinhu27 Nov 24, 2026
ce6dc80
Preserve Docker PATH when the image has no Git executable
crispinhu27 Nov 24, 2026
6bcb0eb
Store native Git helpers in the Runner user cache
crispinhu27 Nov 24, 2026
bf0a857
Fix Runner workspace preparation and HTTP Git compatibility
crispinhu27 Nov 24, 2026
c3379b0
Support HTTP credentials for Git installed during Docker runs
crispinhu27 Nov 24, 2026
3efd8f8
Merge main into generic HTTP Git branch
crispinhu27 Nov 24, 2026
ef0d723
Require a distinct Runner version for plain HTTP Git
crispinhu27 Nov 24, 2026
ca5b574
Merge main and preserve HTTP Git helpers in login shells
crispinhu27 Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions chatbot/src/QuickAccessWizard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -562,12 +562,20 @@ function parseGitHubRepo(raw) {
};
}

// Explicit SSH keeps its transport. Managed HTTPS links use the configured host.
// An ordinary managed link keeps its provider identity. Clone commands can
// explicitly choose plaintext transport.
export function parseGongfengRepo(raw, host = "") {
if (globalThis.LoopForgeExplicitHTTPClone(raw)) {
return globalThis.LoopForgeGitHTTPRepository(raw);
}
return globalThis.LoopForgeGitSSH(raw) ||
globalThis.LoopForgeGongfengRepository(raw, host) ||
globalThis.LoopForgeGitHTTPS(raw) ||
parseGitHubRepo(raw);
parseGitHubRepo(raw) ||
globalThis.LoopForgeGitHTTPRepository(raw);
}

function parseSavedRepo(repo, host) {
return parseGongfengRepo(repo?.provider === "http" ? globalThis.LoopForgeGitRepositoryReference(repo) : repo?.cloneUrl, host);
}

function slugifyProjectId(value) {
Expand Down Expand Up @@ -951,7 +959,14 @@ export default function QuickAccessWizard({
const http = fresh.gitHttpCredentialsConfigured
? await api(`/api/users/${encodeURIComponent(userId)}/git-http-credentials`).catch(() => [])
: [];
if (current()) setGitHttpHosts(http.map(item => item.host));
const savedHosts = Array.isArray(http) ? http.map(item => item.host) : [];
const authorized = savedHosts.some(host => host.startsWith("http://"))
? await api("/api/git-http-hosts").catch(() => [])
: [];
if (current()) {
const authorizedHosts = new Set(Array.isArray(authorized) ? authorized.map(item => item.host) : []);
setGitHttpHosts(savedHosts.filter(host => !host.startsWith("http://") || authorizedHosts.has(host)));
}
})
.catch(() => {})
.finally(() => { if (current()) setCredentialsPending(false); });
Expand Down Expand Up @@ -1073,19 +1088,19 @@ export default function QuickAccessWizard({
const wizardStepCount = STEPS.length - 1;
const gitHubReady = Boolean(storedUser?.gitHubCredentialConfigured);
const gongfengReady = Boolean(storedUser?.gitTokenOAuth);
const hasGit = gitHubReady || gongfengReady || Boolean(storedUser?.gitSshKeyConfigured || storedUser?.gitHttpCredentialsConfigured);
const hasGit = gitHubReady || gongfengReady || Boolean(storedUser?.gitSshKeyConfigured) || gitHttpHosts.length > 0;
const sshKeysLoaded = sshCredentials.userId === user?.id && sshCredentials.keys !== null;
const hasSSHKey = (remote) => sshKeysLoaded && !sshCredentials.error && sshCredentials.keys.some(
(key) => globalThis.LoopForgeGitSSHHost(key.host) === remote?.host,
);
const gitAccess = (repo) => {
if (repo?.provider === "ssh") return { label: "Git SSH", ready: hasSSHKey(repo) };
if (repo?.provider === "https") return { label: "Git HTTPS", ready: gitHttpHosts.includes(repo.host) };
if (["http", "https"].includes(repo?.provider)) return { label: `Git ${repo.provider.toUpperCase()}`, ready: gitHttpHosts.includes(repo.host) };
if (repo?.provider === "github") return { label: "GitHub", ready: gitHubReady };
if (repo?.provider === "gongfeng") return { label: "工蜂", ready: gongfengReady };
return { label: "Git", ready: hasGit };
};
const selectedRepo = (bindRepoNow && parsedRepo) || parseGongfengRepo(defaultRepo?.cloneUrl, gongfengHost);
const selectedRepo = (bindRepoNow && parsedRepo) || parseSavedRepo(defaultRepo, gongfengHost);
const repoAccess = gitAccess(selectedRepo);
const readyCLIs = EXECUTORS.filter(cli => personalEngineConfigured(storedUser, cli.id));
const cliReady = readyCLIs.length > 0 || Boolean(sponsoredModel);
Expand Down Expand Up @@ -1178,7 +1193,7 @@ export default function QuickAccessWizard({
}
if (bindRepoNow && repoUrl.trim() && !parsedRepo) {
setError(
"请输入 Git HTTPS 仓库链接或 Git SSH 克隆地址。",
"请输入 Git HTTP(S) 仓库链接或 Git SSH 克隆地址。",
);
return;
}
Expand Down Expand Up @@ -1236,7 +1251,7 @@ export default function QuickAccessWizard({
const existingRepo = (repositories || []).find(
(repo) =>
repo.projectId === targetProject.id &&
(["ssh", "https"].includes(parsedRepo.provider)
(["ssh", "http", "https"].includes(parsedRepo.provider)
? repo.cloneUrl === parsedRepo.cloneUrl
: repo.gongfengProjectId === parsedRepo.project ||
repo.webUrl === parsedRepo.webUrl),
Expand Down Expand Up @@ -1366,7 +1381,7 @@ export default function QuickAccessWizard({
repository: boundRepo,
workflow: provisionedWorkflow || activeWorkflow,
roles: roles.map(({ id, name }) => ({ id, name })),
gitAccess: gitAccess(parseGongfengRepo(boundRepo?.cloneUrl, gongfengHost)),
gitAccess: gitAccess(parseSavedRepo(boundRepo, gongfengHost)),
cliNames: EXECUTORS.filter(cli => personalEngineConfigured(storedUser, cli.id)).map(cli => cli.label),
});
setPhase("success");
Expand Down Expand Up @@ -1868,7 +1883,7 @@ export default function QuickAccessWizard({
? "旧项目可直接追加新仓库,复用已有流程与角色;留空则沿用现有仓库"
: "沿用项目现有仓库与流程"
: bindRepoNow
? "粘贴 Git HTTPS 链接或 Git SSH 地址,自动设为项目默认仓库"
? "粘贴 Git HTTP(S) 链接或 Git SSH 地址,自动设为项目默认仓库"
: "已跳过,可在派发需求或项目配置中再绑定"}
</span>
</div>
Expand Down Expand Up @@ -1925,7 +1940,7 @@ export default function QuickAccessWizard({
{projectMode === "existing" &&
projectRepos.length
? "新增仓库地址(可选)"
: "Git HTTPS 链接或 Git SSH 地址"}
: "Git HTTP(S) 链接或 Git SSH 地址"}
</span>
<input
className="qa-input qa-mono"
Expand Down Expand Up @@ -1972,7 +1987,7 @@ export default function QuickAccessWizard({
</p>
) : (
<p key="help" className="qa-hint">
支持 Git HTTPS 链接或 Git SSH 地址,例如 <code>git@gitlab.com:group/repo.git</code>。
支持 Git HTTP(S) 链接或 Git SSH 地址,例如 <code>git@gitlab.com:group/repo.git</code>。
</p>
)}
{selectedRepo?.provider === "ssh" && sshKeysLoaded && !repoAccess.ready ? (
Expand Down
41 changes: 39 additions & 2 deletions chatbot/tests/quick-access-wizard.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ const { project, user, apiMock, writeMock, mockState } = vi.hoisted(() => {
id: 1, loginName: "tester", chineseName: "测试",
gitHubCredentialConfigured: false, codeBuddyApiKeyConfigured: false,
...mockState.savedCredentials,
} : user];
} : { ...user, gitHttpCredentialsConfigured: Boolean(mockState.httpCredentials.length) }];
if (path === "/api/projects") return [project];
if (path === "/api/repositories") return [];
if (path === "/api/users/1/git-ssh-keys") return mockState.sshKeys || [];
if (path === "/api/users/1/git-http-credentials") return mockState.httpCredentials;
if (path === "/api/git-http-hosts") return mockState.httpAuthorizations;
if (path === "/api/workflows")
return [
{
Expand All @@ -35,7 +37,7 @@ const { project, user, apiMock, writeMock, mockState } = vi.hoisted(() => {
if (path.includes("/agents")) return [];
return [];
});
const mockState = { failClone: false, unconfigured: false, sshKeys: null, savedCredentials: {}, gitVerification: null };
const mockState = { failClone: false, unconfigured: false, sshKeys: null, httpCredentials: [], httpAuthorizations: [], savedCredentials: {}, gitVerification: null };
const writeMock = vi.fn(async (path, body) => {
if (path === "/api/users/1/git-token/verify") return mockState.gitVerification;
if (path === "/api/projects") return { ...project, ...body };
Expand Down Expand Up @@ -75,6 +77,12 @@ describe("QuickAccessWizard", () => {
expect(parseGongfengRepo("https://git.review.test:8443/acme/widgets", "git.review.test:8443")).toMatchObject({
provider: "gongfeng", project: "acme/widgets", cloneUrl: "https://git.review.test:8443/acme/widgets.git",
});
expect(parseGongfengRepo("http://git.review.test:8443/acme/widgets.git", "git.review.test:8443")).toMatchObject({
provider: "gongfeng", project: "acme/widgets", cloneUrl: "https://git.review.test:8443/acme/widgets.git",
});
expect(parseGongfengRepo("git clone http://git.review.test:8443/acme/widgets.git", "git.review.test:8443")).toMatchObject({
provider: "http", host: "http://git.review.test:8443", cloneUrl: "http://git.review.test:8443/acme/widgets.git",
});
expect(parseGongfengRepo("https://github.com/acme/widgets")).toEqual({
project: "github:acme/widgets",
provider: "github",
Expand Down Expand Up @@ -193,6 +201,35 @@ describe("QuickAccessWizard", () => {
}
});

test("shows the HTTP token as unavailable when the instance authorization is revoked", async () => {
const host = "http://git.review.test:8080";
mockState.httpCredentials = [{ id: "token", host }];
mockState.httpAuthorizations = [{ host, platform: "other" }];
const userAction = userEvent.setup();
try {
render(<QuickAccessWizard open user={user} projects={[project]} projectId="p1" sponsoredModel="m1" />);
await waitFor(() => expect(apiMock).toHaveBeenCalledWith("/api/git-http-hosts"));
await userAction.click(screen.getByRole("button", { name: "下一步" }));
const address = await screen.findByPlaceholderText(/https:\/\/github.com\/owner\/repo/);
await userAction.type(address, `${host}/team/repo.git`);
await userAction.click(screen.getByRole("button", { name: "下一步" }));
expect(await screen.findByText(/Git HTTP 已配置/)).toBeVisible();

mockState.httpAuthorizations = [];
await act(async () => {
window.dispatchEvent(new MessageEvent("message", {
origin: location.origin,
source: window.parent,
data: { type: "agentflow-credentials-changed" },
}));
});
expect(await screen.findByText(/Git HTTP 未配置/)).toBeVisible();
} finally {
mockState.httpCredentials = [];
mockState.httpAuthorizations = [];
}
});

test("keeps the wizard open when configuring an executor and refreshes it on return", async () => {
mockState.unconfigured = true;
const userAction = userEvent.setup();
Expand Down
76 changes: 76 additions & 0 deletions docs/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,73 @@ paths:
application/json:
schema: {type: array, items: {$ref: "#/components/schemas/GitHTTPSHostChoice"}}
"403": {$ref: "#/components/responses/Forbidden"}
/api/git-http-hosts:
get:
tags: [Repositories]
operationId: listGitHTTPHostChoices
summary: List explicitly authorized plaintext Git instances for the signed-in user
responses:
"200":
description: Endpoint and provider choices for personal access tokens
content:
application/json:
schema:
type: array
items:
type: object
required: [host, platform]
properties:
host: {type: string, example: "http://git.example.org:8080"}
platform: {type: string, enum: [other]}
"403": {$ref: "#/components/responses/Forbidden"}
/api/platform/git-http-hosts:
get:
tags: [Repositories]
operationId: listPlatformGitHTTPHosts
summary: List plaintext Git host authorizations
responses:
"200":
description: Authorized hosts and ports
content:
application/json:
schema: {type: array, items: {$ref: "#/components/schemas/PlatformGitHTTPHost"}}
"403": {$ref: "#/components/responses/Forbidden"}
post:
tags: [Repositories]
operationId: createPlatformGitHTTPHost
summary: Authorize a plaintext Git host and port
requestBody:
required: true
content:
application/json:
schema: {$ref: "#/components/schemas/PlatformGitHTTPHost"}
responses:
"201":
description: Saved authorization
content:
application/json:
schema: {$ref: "#/components/schemas/PlatformGitHTTPHost"}
"400": {description: Invalid HTTP host}
"403": {$ref: "#/components/responses/Forbidden"}
"409": {description: The HTTP host and port are already authorized}
/api/platform/git-http-hosts/{host}:
parameters:
- {name: host, in: path, required: true, schema: {type: string}, example: "git.example.org:8080"}
- name: If-Match
in: header
required: true
schema: {type: string}
description: Quote the revision returned when the authorization was read or saved.
delete:
tags: [Repositories]
operationId: deletePlatformGitHTTPHost
summary: Revoke authorization for a plaintext Git host
responses:
"204": {description: Authorization revoked}
"400": {description: Invalid host or revision}
"403": {$ref: "#/components/responses/Forbidden"}
"412": {description: The registration has changed or been removed}
"428": {description: The current registration revision is required}
/api/platform/git-https-hosts:
get:
tags: [Repositories]
Expand Down Expand Up @@ -4840,6 +4907,15 @@ components:
example: "[fd00::2]:8443"
description: Git hostname or IPv6 address. An IPv6 address with a port uses brackets.
platform: {type: string, enum: [github, gitlab, other]}
PlatformGitHTTPHost:
type: object
required: [host]
properties:
host:
type: string
example: "10.0.0.5:8080"
description: Plaintext Git hostname or IP address. The default port is 80.
revision: {type: string, readOnly: true, description: Opaque revision for conditional removal.}
PlatformGitHTTPSHost:
allOf:
- $ref: "#/components/schemas/GitHTTPSHostChoice"
Expand Down
10 changes: 10 additions & 0 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ The platform checks the approved addresses before dialing for token verification

When migrating a host from deployment CIDRs, include every IP the platform should be able to reach in the authorization. To rotate an address, edit the saved list and review the added and removed addresses before confirming.

### Git repositories over HTTP

In **Platform administration → Git Host Trust**, enter an HTTP instance address and select **Authorize**. This accepts hostnames and literal IP addresses, such as `http://git.example.org:8080`, `http://10.0.0.5:8080` or `http://[fd00::2]:8080`. HTTP sends credentials in cleartext.

Under **Personal settings → Git access tokens**, select the authorized HTTP instance and enter your token and the server's Git authentication username if required. Add the repository using its `http://` clone URL. For a host that also has a managed provider, paste the `git clone http://host/team/repo.git` command to explicitly choose HTTP. **Check repository access** runs `git ls-remote` against a repository at that exact endpoint. A successful check confirms read access. A push also requires a server that accepts pushes and credentials with write access.

HTTP and HTTPS have separate authorizations and personal credentials. Git resolves hostnames using the execution environment. Platform-managed Git disables redirects for authorized HTTP credentials. HTTP repositories on an execution machine require Runner 0.12.4 or later. The Git transport supports generic repositories. PR and MR APIs depend on the hosting provider.

If a Docker image lacks Git, the SOP can install it and use the same host-scoped credential helper in that script. The installed Git uses its own HTTP redirect settings.

### Git repositories over SSH

Use Git SSH for GitLab.com, self-managed GitLab, Gitea, Gogs, GitHub, and other Git hosts that offer this transport. In **Project settings → Code repositories** or **Quick access**, enter the clone address, such as `git@gitlab.com:group/repo.git` or `ssh://git@git.example.org:2222/group/repo.git`, and select the existing default branch. GitHub HTTPS continues to use GitHub authorization or a PAT.
Expand Down
Loading
Loading