Skip to content

feat(auth/githubapp): support client ID as alternative to numeric app ID for JWT iss claim #1291

Description

@Erik-Schuetze

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions