Skip to content

feat(knowledge): support HTTPS + PAT auth for private git repos - #183

Open
wbear1 wants to merge 1 commit into
ongridio:mainfrom
wbear1:feat/knowledge-https-credential
Open

wbear1 wants to merge 1 commit into
ongridio:mainfrom
wbear1:feat/knowledge-https-credential

Conversation

@wbear1

@wbear1 wbear1 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What

Adds HTTPS + Personal Access Token authentication for the knowledge base's
code-repo integration, so operators can clone/sync private Git repos over
HTTPS (e.g. a self-hosted GitLab) — alongside the existing SSH identity flow.

Why

Today the knowledge base can only authenticate to private repos via SSH keys.
Many environments hand out HTTPS PATs instead of deploy keys, so private
https://… repos can't be ingested. This closes that gap.

How

Backend

  • New https_credentials table (GORM AutoMigrate) with CRUD across store / biz
    / server layers, mirroring the existing SSH identity design for consistency.
  • Per-host credential matching — a repo URL selects its token by host (glob
    patterns supported in the hosts field).
  • Token injected via a temporary GIT_ASKPASS script with
    GIT_TERMINAL_PROMPT=0; the askpass file is owner-only (0600) and removed
    after use. The token is never embedded in the URL.
  • Tokens are write-only: stored server-side, never echoed back (DTO exposes
    has_token only).
  • annotateGitError gains an HTTPS branch distinguishing "no credential for
    host" from "credential rejected", matching the existing SSH hints.

Frontend

  • HTTPSCredentialsCard on the Code repos page: list / add / edit / delete,
    hosts matching, write-only token entry.
  • Repo-creation error hint tells operators to add an HTTPS credential when a
    private HTTPS repo has none.

Testing

  • go test ./internal/manager/biz/knowledge/... ./internal/manager/server/knowledge/... — pass
  • npm run build in web/ — pass
  • Unit tests cover buildHTTPSEnv askpass generation, buildGitAuthEnv
    routing, and per-host matching. An optional real-repo clone e2e smoke test
    skips when no test-repo env is provided.

One logical change; commit follows Conventional Commits.

Author confirmation

  • I have read and agree to the project contribution guide in CONTRIBUTING.md.

Add HTTPS credential support so the knowledge base can clone and sync
private Git repositories that require a Personal Access Token, alongside
the existing SSH identity flow.

Backend:
- New https_credentials table (GORM AutoMigrate) with CRUD in the store,
  biz, and server layers, mirroring the existing SSH identity design.
- Per-host credential matching so a repo URL selects the right token by
  its host (glob patterns supported in the hosts field).
- Token is injected via a temporary GIT_ASKPASS script with GIT_TERMINAL_
  PROMPT=0; the askpass file is created owner-only (0600) and removed
  after use. The token is never embedded in the URL.
- Tokens are write-only: stored server-side and never echoed back to the
  client (DTO exposes has_token only).
- annotateGitError gains an HTTPS branch distinguishing "no credential
  configured for host" from "credential rejected", matching the SSH hints.

Frontend:
- HTTPSCredentialsCard on the Code repos page: list, add, edit, delete,
  with hosts matching and write-only token entry.
- Repo-creation error hint points operators to configure an HTTPS
  credential when a private HTTPS repo has none.

Tests cover buildHTTPSEnv askpass generation, buildGitAuthEnv routing,
per-host matching, and an optional real-repo clone e2e smoke test that
skips when no test repo env is provided.
@wbear1
wbear1 requested a review from singchia as a code owner July 9, 2026 06:48
@singchia

Copy link
Copy Markdown
Member

Reviewed the scope again. This PR does include UI changes, mainly on the Code repos / Knowledge repos page:

  • new Credentials · HTTPS card
  • list / empty / loading / error states for HTTPS credentials
  • Add HTTPS credential modal
  • Edit HTTPS credential modal with write-only token behavior
  • delete confirmation / post-delete state
  • repo sync failure hint when a private HTTPS repo has no matching credential

Before merge, please add screenshots for the affected interactions, not just backend test results. At minimum:

  1. Code repos page with the HTTPS credentials card collapsed and expanded
  2. Empty HTTPS credentials state
  3. Add credential modal
  4. Edit credential modal showing token is not prefilled and blank means keep existing token
  5. A configured credential row with hosts / username / has-token state
  6. Private HTTPS repo sync error hint pointing the operator to add a matching HTTPS credential

Dark mode is enough if this page is dark-only in the current product path; include light mode too if the page supports it.

@wbear1

wbear1 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@singchia Added the UI screenshots. This page supports both light and dark, so both themes are included. Screenshots are attached below:

Light
1
image
3
4
10

Dark
5
6
7
8
9

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