Skip to content

[v2] 自定义插件市场来源支持内部 Git 认证:设置页配置、同步时使用 - #365

Merged
EricWvi merged 4 commits into
ora-space:mainfrom
TannyXie:fix/1097-market-git-auth
Nov 13, 2026
Merged

EricWvi merged 4 commits into
ora-space:mainfrom
TannyXie:fix/1097-market-git-auth

Conversation

@TannyXie

Copy link
Copy Markdown
Contributor

做了什么

自定义插件市场来源支持 HTTPS Git 认证(用户名加令牌或密码),供内网部署使用。

  1. 存储:v2_market_sources 新增 git_credentials 列,与 S3 凭据一样以 AES-256-GCM(V2_MARKET_CREDENTIAL_KEY)加密存库,绑定到空间和来源;读取接口只返回 gitConfigured 是否已配置,绝不返回凭据;可整体替换、保留或清除。
  2. 同步:手动同步从库中解密凭据,经 gitAuthEnv 以 http.extraHeader 形式(通过 GIT_CONFIG_COUNT 环境变量注入 git 配置)交给 git clone,凭据不进入仓库地址、命令行参数、日志或工作目录的 git 配置;失败时区分认证失败与网络失败,来源上分别显示"仓库认证失败,请检查 Git 用户名和令牌。"与"请检查仓库地址和分支。",并保留上一版目录。
  3. 前端:来源编辑表单(高级设置)增加"Git 认证"栏,可填用户名 + 令牌/密码保存或替换,已配置时显示提示并可勾选清除。

测试

  • pluginmarket:gitAuthEnv 只注入请求头(凭据不落到其它环境项);gitAuthError 正确区分认证失败与网络失败;带认证的本地 HTTPS Git 仓库(git http-backend + Basic Auth)能同步、错误凭据失败且密码不泄漏到错误输出。
  • store:Git 凭据加密存储、读取不返回、无关编辑保留、新凭据替换、显式清除、空值拒绝。
  • 前端:表单配置/替换/清除/保持不变各有一条测试。

本地验证:v2-server go test ./... 全绿;frontend-v2 808 个测试、typecheck、lint、build 全绿。

v2 流程,送审附截图(见运行 issue)。

Resolve the conflict in v2-server/internal/store/market_sources.go: main
removed the role check at the top of ChangeMarket (cloud#363 moved it to
the owner route), so the sync branch now declares e itself; keep the
git_credentials column this branch reads there.

Update the Git credential tests to the store signatures after cloud#363:
TenantSpaces takes a store.Access, and ChangeMarket and MarketSources no
longer take the caller.
Saved Git credentials are sealed to the source namespace, and the
namespace follows the repository URL. Editing a source's URL without
touching its authentication kept a ciphertext the new namespace could
not open: the page still showed the credentials as configured while
every sync failed with market_credentials_unavailable.

Reject such an edit, as S3 credentials already are, unless it supplies
new credentials or clears the saved ones. The source stays unchanged
when the edit is rejected. The form and README say so.
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.

2 participants