Skip to content

Commit 00e59da

Browse files
authored
feat: Add GitHub App gateway credentials (#431)
* feat: Add GitHub App gateway credentials * fix: Fail closed for cached GitHub App auth * fix: Skip credentials for non-HTTPS upstreams * fix: Skip non-repo GitHub credential URLs * feat: load GitHub App credentials from config * feat: add GitHub App serve flags * fix: report daemon GitHub App credentials in doctor * fix: keep daemon GitHub App auth in config
1 parent e8fe637 commit 00e59da

20 files changed

Lines changed: 1910 additions & 37 deletions

docs/gateway.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,16 +214,54 @@ Not wired yet:
214214

215215
## Credentials
216216

217-
Host-side credentials are provided via environment variables:
217+
Host-side GitHub App credentials can be configured in the host runtime config:
218+
219+
```yaml
220+
gateway:
221+
credentials:
222+
github_app:
223+
app_id: "3817917"
224+
installation_id: "134770928"
225+
private_key_file: /Users/lachlan/.config/cleanroom/github-app.pem
226+
repo_prefixes:
227+
- buildkite/
228+
```
229+
230+
`private_key_file` is read by the host-side `cleanroom serve` process. It should
231+
point at a local PEM file readable only by the daemon user.
232+
233+
Installed daemons read this from runtime config. `cleanroom daemon install` does
234+
not persist GitHub App credentials as service arguments.
235+
236+
Foreground `cleanroom serve` also supports command-line overrides for the same
237+
GitHub App settings. These flags use Kong environment bindings, so the matching
238+
environment variables can be used instead of flags:
239+
240+
| Flag | Environment variable | Purpose |
241+
|------|----------------------|---------|
242+
| `--github-app-id` | `CLEANROOM_GITHUB_APP_ID` | GitHub App ID for host-side GitHub Git authentication |
243+
| `--github-app-installation-id` | `CLEANROOM_GITHUB_APP_INSTALLATION_ID` | GitHub App installation ID |
244+
| `--github-app-private-key-file` | `CLEANROOM_GITHUB_APP_PRIVATE_KEY_FILE` | Path to PEM-encoded GitHub App private key |
245+
| `--github-app-repo-prefixes` | `CLEANROOM_GITHUB_APP_REPO_PREFIXES` | Comma-separated `owner/` or `owner/repo` scopes where GitHub App credentials may be used |
246+
247+
Static token credentials are also supported through environment variables:
218248

219249
| Variable | Purpose |
220250
|----------|---------|
221251
| `CLEANROOM_GITHUB_TOKEN` | GitHub authentication |
222252
| `CLEANROOM_GITLAB_TOKEN` | GitLab authentication |
223253

224254
Credentials are injected into upstream requests by the gateway. They are never
225-
exposed to the guest environment. The same host-side credential provider chain
226-
is used by the embedded `content-cache` upstream clients.
255+
exposed to the guest environment. GitHub App credentials take precedence for
256+
matching `github.com` Git remotes when configured; token mint failures fail the
257+
upstream request instead of falling back to unauthenticated Git or host
258+
credential helpers. GitHub repositories outside
259+
the configured `repo_prefixes` continue through the rest of the credential
260+
chain. If runtime config does not define `gateway.credentials.github_app`, a
261+
foreground `cleanroom serve` process uses any GitHub App values provided by
262+
`serve` flags or their bound environment variables. The same host-side
263+
credential provider chain is used by the embedded `content-cache` upstream
264+
clients.
227265

228266
## Configuration
229267

0 commit comments

Comments
 (0)