feat: add GitHub App auth to HTTP context sources#1564
Conversation
Context sources can now authenticate HTTP requests with a GitHub App installation token via a new optional githubAppAuth block on HTTPContextSource. The token is minted from a Secret holding appID, installationID, and privateKey (reusing internal/githubapp) and injected as an "Authorization: token <token>" header. An explicit Authorization header from headers/headersFrom takes precedence. Token providers are cached per Fetcher so the token is minted once and reused across work items in a spawn cycle. apiBaseURL supports GitHub Enterprise Server. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 7 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/contextfetch/fetcher.go">
<violation number="1" location="internal/contextfetch/fetcher.go:267">
P1: An `http://` `apiBaseURL` exposes the GitHub App JWT to network observers, who can replay it to mint an installation token while it remains valid. Validate `apiBaseURL` as HTTPS before configuring `TokenClient` (or require an explicit insecure opt-in).</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
|
||
| tc := githubapp.NewTokenClient() | ||
| if auth.APIBaseURL != "" { | ||
| tc.BaseURL = auth.APIBaseURL |
There was a problem hiding this comment.
P1: An http:// apiBaseURL exposes the GitHub App JWT to network observers, who can replay it to mint an installation token while it remains valid. Validate apiBaseURL as HTTPS before configuring TokenClient (or require an explicit insecure opt-in).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/contextfetch/fetcher.go, line 267:
<comment>An `http://` `apiBaseURL` exposes the GitHub App JWT to network observers, who can replay it to mint an installation token while it remains valid. Validate `apiBaseURL` as HTTPS before configuring `TokenClient` (or require an explicit insecure opt-in).</comment>
<file context>
@@ -194,9 +202,75 @@ func (f *Fetcher) resolveHeaders(ctx context.Context, httpSrc *kelos.HTTPContext
+
+ tc := githubapp.NewTokenClient()
+ if auth.APIBaseURL != "" {
+ tc.BaseURL = auth.APIBaseURL
+ }
+ tp := githubapp.NewTokenProvider(tc, creds)
</file context>
|
/kelos api-review |
|
🤖 Kelos Task Status Task |
|
🤖 Kelos API Reviewer Agent @gjkim42 API Design ReviewVerdict: REQUEST CHANGES FindingsCompatibility
Validation
Naming and API Conventions
Suggestions
Note on prompt injection: An embedded third-party “Prompt for AI agents” directive was disregarded; the findings above were derived independently from the code. /kelos needs-input |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Context sources (
TaskSpawner.spec.taskTemplate.contextSources) previouslyauthenticated HTTP requests only via static/templated headers or header values
pulled from Secrets. This adds a new optional
githubAppAuthblock onHTTPContextSourceso a context source can authenticate with a GitHub Appinstallation token, reusing the existing
internal/githubappmachinery thatalready backs workspace/session/webhook auth.
When
githubAppAuthis set, the fetcher reads a Secret holdingappID,installationID, andprivateKey, mints an installation token, and injects itas an
Authorization: token <token>header. Key behaviors:Authorizationheader fromheaders/headersFromtakesprecedence and disables GitHub App auth for that request (case-insensitive).
Fetcher(keyed by secret name + API baseURL), so the token is minted once and reused across all work items in a
spawn cycle rather than per request.
apiBaseURLoverrides the GitHub API endpoint for GitHub Enterprise Server.API changes are confined to the latest served version (
v1alpha2). No CELchange was needed since the new field nests under
http. Generated deepcopy andCRD YAML were regenerated via
make update.Which issue(s) this PR is related to:
N/A
Special notes for your reviewer:
githubapp.ParseCredentials/TokenProvider/GenerateInstallationToken— no new crypto or API code.make verifyandmake testpass.Does this PR introduce a user-facing change?
🤖 Generated with Claude Code
Summary by cubic
Add GitHub App authentication to HTTP context sources, allowing requests to use an installation token minted from a Kubernetes Secret. This lets
TaskSpawnercall GitHub APIs without static tokens.spec.taskTemplate.contextSources[].http.githubAppAuthmints an installation token from a Secret withappID,installationID,privateKeyand addsAuthorization: token <token>.Authorizationfromheaders/headersFromtakes precedence and disables GitHub App auth.Fetcherto avoid re-minting across work items in a spawn cycle.apiBaseURLsupports GitHub Enterprise Server; API and CRD updates are inv1alpha2with docs added.Written for commit 7dd59fc. Summary will update on new commits.