Title: feat(auth/githubapp): support client ID as alternative to numeric app ID for JWT iss claim
GitHub's documentation now recommends using the client ID (e.g. Iv23liXXXXXXX) instead of
the numeric app ID as the iss claim when generating JWTs for GitHub App authentication:
docs page for github.com
docs page for GHE 3.20
Currently auth/githubapp/client.go only accepts a numeric githubAppID, parsed with
strconv.ParseInt and used as the integer JWT issuer.
Problem
Users migrating from PATs to GitHub Apps are storing credentials using the client ID because
that is what GitHub now surfaces and recommends. Having to separately look up the numeric app ID
just for Flux is unnecessary friction, and the numeric ID is an internal identifier that GitHub
themselves are steering users away from.
Proposed change
Add an optional githubAppClientID secret key. If present and githubAppID is absent, use it
as the string iss claim in the JWT. The GitHub API accepts both forms.
Concretely in auth/githubapp/client.go:
- Add
KeyAppClientID = "githubAppClientID" constant
- Store it as a
clientID string field on Client
- In
WithAppData, populate it when present
- In
New, accept either appID != 0 or clientID != "" as valid
- In
createJWT, use the client ID string as iss when app ID is zero
No breaking change -- githubAppID continues to work exactly as today.
Context
This came up while migrating a Flux GitRepository from a PAT to a GitHub App on a GitHub
Enterprise Server 3.20 instance. When creating the GitHub App, the UI prominently shows the
client ID (e.g. Iv23liXXXXXXX) as the app identifier. The numeric app ID is a secondary field
that users have to actively look for. Supporting githubAppClientID in the secret would let users
use the credential GitHub presents to them directly, without an extra lookup step.
I would be happy to submit a PR if the approach looks reasonable.
Title: feat(auth/githubapp): support client ID as alternative to numeric app ID for JWT iss claim
GitHub's documentation now recommends using the client ID (e.g.
Iv23liXXXXXXX) instead ofthe numeric app ID as the
issclaim when generating JWTs for GitHub App authentication:docs page for github.com
docs page for GHE 3.20
Currently
auth/githubapp/client.goonly accepts a numericgithubAppID, parsed withstrconv.ParseIntand used as the integer JWT issuer.Problem
Users migrating from PATs to GitHub Apps are storing credentials using the client ID because
that is what GitHub now surfaces and recommends. Having to separately look up the numeric app ID
just for Flux is unnecessary friction, and the numeric ID is an internal identifier that GitHub
themselves are steering users away from.
Proposed change
Add an optional
githubAppClientIDsecret key. If present andgithubAppIDis absent, use itas the string
issclaim in the JWT. The GitHub API accepts both forms.Concretely in
auth/githubapp/client.go:KeyAppClientID = "githubAppClientID"constantclientID stringfield onClientWithAppData, populate it when presentNew, accept eitherappID != 0orclientID != ""as validcreateJWT, use the client ID string asisswhen app ID is zeroNo breaking change --
githubAppIDcontinues to work exactly as today.Context
This came up while migrating a Flux
GitRepositoryfrom a PAT to a GitHub App on a GitHubEnterprise Server 3.20 instance. When creating the GitHub App, the UI prominently shows the
client ID (e.g.
Iv23liXXXXXXX) as the app identifier. The numeric app ID is a secondary fieldthat users have to actively look for. Supporting
githubAppClientIDin the secret would let usersuse the credential GitHub presents to them directly, without an extra lookup step.
I would be happy to submit a PR if the approach looks reasonable.