Skip to content

Add githubAppClientID as an alternative to githubAppID - #1296

Merged
matheuscscp merged 1 commit into
fluxcd:mainfrom
Erik-Schuetze:githubapp-client-id
Sep 22, 2026
Merged

matheuscscp merged 1 commit into
fluxcd:mainfrom
Erik-Schuetze:githubapp-client-id

Conversation

@Erik-Schuetze

Copy link
Copy Markdown
Contributor

Refs: #1291

GitHub accepts either the numeric AppID or the ClientID of GH Apps as the JWT iss claim, and recommends the ClientID in the official docs (GitHub, GHE). pkg currently only accepts the numeric AppID, so this PR adds githubAppClientID as an alternative across auth/githubapp (the JWT consumer) and runtime/secrets (the secret writer and reader). Existing secrets using only AppID are unaffected.

AppID and ClientID are treated as mutually exclusive. This is enforced in New, MakeGitHubAppSecret, and GitHubAppDataFromSecret, mirroring the existing installationOwner / installationID handling.
They identify the same app for a single iss claim, so this keeps the behaviour unambiguous and avoids silently ignoring one identity when both are supplied.
The ClientID is treated as a regular string, since GitHub documents no format for it (The ClientIDs I checked on GHE and GitHub also differed from each other with no common prefix).
As pkg is a GA dependency consumed by all Flux controllers, MakeGitHubAppSecret keeps appID as a positional parameter and adds clientID via an option, because any change to the positional parameters of this exported function would break every existing consumer.
If the preferred solution is to change to symmetric options (WithGitHubAppID + WithGitHubAppClientID) and accept the function signature break, I'm happy to switch.

Two behaviour changes to note, given the GA compatibility guarantee:

  • changed the error message of MakeGitHubAppSecret from "githubAppID is required" to "exactly one of githubAppID or githubAppClientID must be provided".
  • buildCacheKey now includes the ClientID, which causes a new token to be requested on version upgrade (a one-time, self-healing re-fetch of short-lived installation tokens).

I applied the change across auth/githubapp and runtime/secrets in pkg so the new ClientID is usable end-to-end. If you prefer I can split it into two PRs.

I added Tests for client-ID-only, both-set (rejected), and neither-set across writer, reader, and JWT issuer generation; make test-auth and make test-runtime pass.

Comment thread runtime/secrets/factory.go Outdated
@Erik-Schuetze

Copy link
Copy Markdown
Contributor Author

appID is now a WithGitHubAppID option. I left the validation unchanged as it was already checking for exactly one of appID/clientID.

As discussed this is a breaking change to the exported MakeGitHubAppSecret signature (positional appID dropped), so downstream callers will need updating.

The force push was just to add the missing DCO sign-off to the commit.

@matheuscscp

Copy link
Copy Markdown
Member

@Erik-Schuetze Please rebase with main (no merge commits!), squash all commits into one, and force-push

GitHub recommends using the App client ID (e.g. Iv23li...) rather than the
numeric App ID as the JWT iss claim; both remain valid. Exactly one of the
two must be provided (mirroring the existing installationOwner/installationID
pattern) — supplying both or neither is an error at every layer.

auth/githubapp: new KeyAppClientID const and clientID field; WithAppData reads
it as an opaque string; New enforces exactly one of appID/clientID; createJWT
uses clientID as the JWT iss when set, else the numeric appID; buildCacheKey
includes clientID to avoid cache-key collisions for client-ID-only clients.

runtime/secrets: new KeyGitHubAppClientID const; WithGitHubAppID and
WithGitHubAppClientID options (both symmetric, positional appID removed);
MakeGitHubAppSecret requires exactly one of the two; GitHubAppDataFromSecret
enforces exactly one on the read path.

Breaking change: MakeGitHubAppSecret no longer takes appID as a positional
argument — callers must use WithGitHubAppID instead.

Refs: fluxcd#1291
Signed-off-by: Erik Schuetze <erik.schuetze@sap.com>
Assisted-by: claude-code/claude-opus-4-8
@Erik-Schuetze

Copy link
Copy Markdown
Contributor Author

Done

@matheuscscp matheuscscp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

Thanks @Erik-Schuetze, nice addition!

@matheuscscp
matheuscscp merged commit c8ffebb into fluxcd:main Sep 22, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants