feat(deploy): P4.2b — mint GitHub App installation token for source=git clones#226
Merged
Merged
Conversation
…it clones A source=git deploy with no stored PAT but linked to a GitHub App installation now clones its private repo with a freshly-minted, short-lived installation token (contents:read, ~1h) instead of requiring a long-lived PAT — the private-repo payoff of the App integration. - DeployHandler gains an installationTokenMinter (interface; github.App satisfies it), wired in NewDeployHandler when GITHUB_APP_ENABLED + key valid (nil otherwise → git clones fall back to PAT/public). SetGitHubApp setter mirrors SetEmailClient/SetComputeProvider. - runDeploy → applyInstallationAuth → installationCloneToken: looks up the deploy's app_github_connection → installation_id, validates the installation belongs to the deploy's team AND isn't suspended (anti-hijack / revocation), mints via the minter. Fail-soft: any miss leaves GitAuth empty (public clone). A stored PAT takes precedence (no mint). - Migration-free (reuses app_github_connections.installation_id). Tests: sqlmock white-box covers applyInstallationAuth + installationCloneToken 100% across every branch (non-git / PAT / app-disabled / no-connection / no-installation-id / installation-missing / suspended / team-mismatch / mint-error / minted), plus NewDeployHandler minter-wiring (valid/bad/disabled). The end-to-end real-DB source=git runDeploy path is covered by the existing TestDeployNew_SourceGit_FlagOn_Accepted. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
deploy.go:414 (SetGitHubApp) was uncovered — the sqlmock tests set the minter via a struct literal. Route through h.SetGitHubApp(minter) in the test helper so the setter is exercised.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A source=git deploy with no stored PAT but linked to a GitHub App installation
now clones its private repo with a freshly-minted, short-lived installation
token (contents:read, ~1h) instead of requiring a long-lived PAT — the
private-repo payoff of the App integration.
satisfies it), wired in NewDeployHandler when GITHUB_APP_ENABLED + key valid
(nil otherwise → git clones fall back to PAT/public). SetGitHubApp setter
mirrors SetEmailClient/SetComputeProvider.
deploy's app_github_connection → installation_id, validates the installation
belongs to the deploy's team AND isn't suspended (anti-hijack / revocation),
mints via the minter. Fail-soft: any miss leaves GitAuth empty (public clone).
A stored PAT takes precedence (no mint).
Tests: sqlmock white-box covers applyInstallationAuth + installationCloneToken
100% across every branch (non-git / PAT / app-disabled / no-connection /
no-installation-id / installation-missing / suspended / team-mismatch /
mint-error / minted), plus NewDeployHandler minter-wiring (valid/bad/disabled).
The end-to-end real-DB source=git runDeploy path is covered by the existing
TestDeployNew_SourceGit_FlagOn_Accepted.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com