Skip to content

Allow use of client id as an app id #4057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 16, 2025
Merged

Conversation

nikola-jokic
Copy link
Collaborator

This change allows client ID not to be an integer only, but also to be a client ID (see https://github.blog/changelog/2024-05-01-github-apps-can-now-use-the-client-id-to-fetch-installation-tokens/).

This change is backwards-compatible.

Fixes #3667

@nikola-jokic nikola-jokic added the gha-runner-scale-set Related to the gha-runner-scale-set mode label Apr 24, 2025
@Copilot Copilot AI review requested due to automatic review settings April 24, 2025 10:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables the use of client IDs as AppIDs by changing the type of the AppID from an integer to a string throughout the codebase while maintaining backwards compatibility. Key changes include:

  • Converting AppID values in tests and production code from int to string.
  • Removing integer parsing logic and updating JWT claims to use the string AppID.
  • Adjusting error messages and tests to match the new string formatting.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
github/actions/multi_client_test.go Updated test cases to use string literals for AppID
github/actions/multi_client.go Changed GitHubAppAuth.AppID to string and removed integer parsing
github/actions/identifier_test.go Updated identifier tests to reflect the string AppID format
github/actions/client.go Modified JWT creation to use string AppID as Issuer
controllers/actions.github.com/resourcebuilder.go Updated secret retrieval to convert AppID to string and use maps.Copy
cmd/ghalistener/config/config_test.go Adjusted error message formatting in tests
cmd/ghalistener/config/config.go Updated error messages and validation for string-based AppID

@@ -18,7 +18,7 @@ import (

type Config struct {
ConfigureUrl string `json:"configure_url"`
AppID int64 `json:"app_id"`
Copy link
Member

Choose a reason for hiding this comment

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

We should probably clarify in the values.yaml file that this field can be either the app id or client id

@@ -23,7 +23,7 @@ type multiClient struct {
}

type GitHubAppAuth struct {
AppID int64
AppID string
Copy link
Member

Choose a reason for hiding this comment

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

nit: Do we want to clarify that this could be both AppID or ClientID?


if !hasToken && !hasPrivateKeyConfig {
return fmt.Errorf("GitHub auth credential is missing, token length: '%d', appId: '%d', installationId: '%d', private key length: '%d", len(c.Token), c.AppID, c.AppInstallationID, len(c.AppPrivateKey))
return fmt.Errorf(`GitHub auth credential is missing, token length: "%d", appId: %q, installationId: "%d", private key length: "%d"`, len(c.Token), c.AppID, c.AppInstallationID, len(c.AppPrivateKey))
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to clarify here that we expect an AppID or a ClientID?

Copy link
Member

@Link- Link- left a comment

Choose a reason for hiding this comment

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

Minor comments

Copy link
Member

@Link- Link- left a comment

Choose a reason for hiding this comment

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

Minor comments

@nikola-jokic
Copy link
Collaborator Author

I pushed a few comments explaining that the app_id can be a client id
I deliberately didn't change the name, so previous charts would still work while extending the functionality.
If the app ID gets deprecated, we can change the field. Otherwise, I wanted to keep minimal changes and at the same time, extend the behavior (since the client id should be used in every place where app id was used previously)

@nikola-jokic nikola-jokic requested a review from Link- May 15, 2025 11:43
@nikola-jokic nikola-jokic merged commit 1dbb88c into master May 16, 2025
19 checks passed
@nikola-jokic nikola-jokic deleted the nikola-jokic/client-id-str branch May 16, 2025 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gha-runner-scale-set Related to the gha-runner-scale-set mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Runner Scale Set Auth Secret Does Not Support GH App Client ID
2 participants