Support GitHub clientID in addition to appID for GitHub App authentication#4606
Conversation
✅ Deploy Preview for docs-kargo-io ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-authored-by: krancour <[email protected]>
|
@copilot the approach to this is entirely wrong. Client ID isn't merely a string representation of the App ID. It's a different identifier and it's not numeric. It is alphanumeric. If you examine
Once we have an application token source in-hand, we should have no trouble using it with So summarize, we need our own implementation of |
Co-authored-by: krancour <[email protected]>
You're absolutely right - my initial approach was fundamentally flawed. I've completely rewritten the implementation to properly handle GitHub Client ID as the alphanumeric identifier it is. The new implementation:
This follows the GitHub documentation you referenced and properly treats app ID and client ID as distinct identifiers. Thanks for the detailed guidance - the solution is much cleaner now. Commit: d4064c3 |
|
|
||
| // kargoApplicationTokenSource represents a GitHub App token source that can handle | ||
| // both numeric app IDs and alphanumeric client IDs. | ||
| type kargoApplicationTokenSource struct { |
There was a problem hiding this comment.
@copilot let's please move all this custom token source code into its own file so it's not cluttering this one. Let's also remove "kargo" from the start of the type name. It doesn't feel necessary.
There was a problem hiding this comment.
I've moved the custom token source code to a separate token_source.go file and removed the "kargo" prefix from the type name. The applicationTokenSource and related code are now better organized and the main app.go file is less cluttered.
Commit: 7efd0f5
…sues Co-authored-by: krancour <[email protected]>
| if data[appIDKey] != nil { | ||
| // Parse as numeric app ID | ||
| var err error | ||
| numericAppID, err = strconv.ParseInt(string(data[appIDKey]), 10, 64) |
There was a problem hiding this comment.
@copilot what's the point of parsing this. It made sense in the original implementation, but the rest of the changes in this PR don't seem to, at any point, need for this to he an actual number. Can't we just keep it as a string?
There was a problem hiding this comment.
You're absolutely right. I've removed the unnecessary parsing of appID to int64. The code now treats both appID and clientID as strings throughout, which is much cleaner and simpler. The cache key generation now uses a consistent string-based hash for both identifiers.
Commit: 50973c3
…e key generation Co-authored-by: krancour <[email protected]>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
| } | ||
|
|
||
| appTokenSource, err := githubauth.NewApplicationTokenSource(appID, decodedKey) | ||
| privateKey, err := parsePrivateKey(decodedKey) |
There was a problem hiding this comment.
@copilot This feels like something our custom token source should be calling in a constructor-like newAppTokenSource() function. It doesn't feel like it belongs here.
There was a problem hiding this comment.
I've moved the private key validation logic to a constructor function newApplicationTokenSource in the token source file. This provides better separation of concerns and keeps the key processing encapsulated within the token source itself.
Commit: e432762
Co-authored-by: krancour <[email protected]>
|
Oh Copilot... Superseded by #4687 |

GitHub now recommends using the Client ID instead of the numeric App ID for GitHub App authentication. This change adds support for
githubAppClientIDas an alternative togithubAppIDin Kargo's GitHub App credential configuration.Changes Made
githubAppClientIDsupport: Users can now use eithergithubAppID(numeric) orgithubAppClientID(string) in their credential secretsgithubAppIDconfigurations continue to work unchangedgithubAppIDorgithubAppClientIDcan be specified (not both)Usage Examples
Using the traditional App ID (numeric):
Using the new Client ID (recommended):
Technical Details
int64for compatibility with the underlyinggo-githubauthlibraryThis resolves the parsing error users encountered when trying to use Client ID in place of App ID, as mentioned in the GitHub documentation.
Fixes #4294.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
get.helm.shcurl -SsL REDACTED -o /tmp/helm-installer-yEL8p3/helm-v3.18.4-linux-amd64.tar.gz.sha256(dns block)metadata.google.internal/tmp/go-build2499390754/b059/kubernetes.test -test.testlogfile=/tmp/go-build2499390754/b059/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.