feat: replace static API token with per-request Gitea PAT pass-through

Callers now supply their own Gitea PAT as a Bearer token; the server validates
it against GET /api/v1/user and threads it through context to all downstream
Gitea API calls. GITEA_API_TOKEN env var and the GiteaAPIToken config field are
removed.
This commit is contained in:
Mathias Bergqvist
2026-05-07 21:04:47 +02:00
parent 9a5d0005c5
commit 923689afa5
6 changed files with 150 additions and 11 deletions

View File

@@ -23,7 +23,7 @@ func main() {
os.Exit(1)
}
giteaClient := gitea.NewClient(cfg.GiteaBaseURL, cfg.GiteaAPIToken)
giteaClient := gitea.NewClient(cfg.GiteaBaseURL, "")
ownerAllow := allowlist.New(cfg.AllowedOwners)
reg := registry.New()
@@ -58,7 +58,11 @@ func main() {
})
mux := http.NewServeMux()
mux.Handle("/mcp", mcp.OriginAllowlist(cfg.OriginAllowlist)(auth.CallerMiddleware(mcpSrv)))
mux.Handle("/mcp", mcp.OriginAllowlist(cfg.OriginAllowlist)(
auth.BearerMiddleware(cfg.GiteaBaseURL,
auth.CallerMiddleware(mcpSrv),
),
))
mux.HandleFunc("/healthz", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok"))