mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-11 03:57:01 +00:00
Allow use of client id as an app id (#4057)
This commit is contained in:
@@ -1212,7 +1212,7 @@ func createJWTForGitHubApp(appAuth *GitHubAppAuth) (string, error) {
|
||||
claims := &jwt.RegisteredClaims{
|
||||
IssuedAt: jwt.NewNumericDate(issuedAt),
|
||||
ExpiresAt: jwt.NewNumericDate(expiresAt),
|
||||
Issuer: strconv.FormatInt(appAuth.AppID, 10),
|
||||
Issuer: appAuth.AppID,
|
||||
}
|
||||
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodRS256, claims)
|
||||
|
||||
@@ -57,7 +57,7 @@ func TestClient_Identifier(t *testing.T) {
|
||||
}
|
||||
defaultAppCreds := &actions.ActionsAuth{
|
||||
AppCreds: &actions.GitHubAppAuth{
|
||||
AppID: 123,
|
||||
AppID: "123",
|
||||
AppInstallationID: 123,
|
||||
AppPrivateKey: "private key",
|
||||
},
|
||||
@@ -90,7 +90,7 @@ func TestClient_Identifier(t *testing.T) {
|
||||
old: defaultAppCreds,
|
||||
new: &actions.ActionsAuth{
|
||||
AppCreds: &actions.GitHubAppAuth{
|
||||
AppID: 456,
|
||||
AppID: "456",
|
||||
AppInstallationID: 456,
|
||||
AppPrivateKey: "new private key",
|
||||
},
|
||||
|
||||
@@ -23,7 +23,8 @@ type multiClient struct {
|
||||
}
|
||||
|
||||
type GitHubAppAuth struct {
|
||||
AppID int64
|
||||
// AppID is the ID or the Client ID of the application
|
||||
AppID string
|
||||
AppInstallationID int64
|
||||
AppPrivateKey string
|
||||
}
|
||||
@@ -124,16 +125,11 @@ func (m *multiClient) GetClientFromSecret(ctx context.Context, githubConfigURL,
|
||||
return m.GetClientFor(ctx, githubConfigURL, auth, namespace, options...)
|
||||
}
|
||||
|
||||
parsedAppID, err := strconv.ParseInt(appID, 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
parsedAppInstallationID, err := strconv.ParseInt(appInstallationID, 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
auth.AppCreds = &GitHubAppAuth{AppID: parsedAppID, AppInstallationID: parsedAppInstallationID, AppPrivateKey: appPrivateKey}
|
||||
auth.AppCreds = &GitHubAppAuth{AppID: appID, AppInstallationID: parsedAppInstallationID, AppPrivateKey: appPrivateKey}
|
||||
return m.GetClientFor(ctx, githubConfigURL, auth, namespace, options...)
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ etFcaQuTHEZyRhhJ4BU=
|
||||
-----END PRIVATE KEY-----`
|
||||
|
||||
auth := &GitHubAppAuth{
|
||||
AppID: 123,
|
||||
AppID: "123",
|
||||
AppPrivateKey: key,
|
||||
}
|
||||
jwt, err := createJWTForGitHubApp(auth)
|
||||
|
||||
Reference in New Issue
Block a user