From d1f21183894865a7708618b14ecce07d7ccde687 Mon Sep 17 00:00:00 2001 From: Phil Kuang Date: Wed, 22 Sep 2021 15:43:40 -0400 Subject: [PATCH] fix(GithubCredentialsProvider): support selective app installs with GHE hosts Signed-off-by: Phil Kuang --- .changeset/khaki-hotels-doubt.md | 5 +++++ packages/integration/src/github/GithubCredentialsProvider.ts | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 .changeset/khaki-hotels-doubt.md diff --git a/.changeset/khaki-hotels-doubt.md b/.changeset/khaki-hotels-doubt.md new file mode 100644 index 0000000000..8bab499f3e --- /dev/null +++ b/.changeset/khaki-hotels-doubt.md @@ -0,0 +1,5 @@ +--- +'@backstage/integration': patch +--- + +Support selective GitHub app installation for GHE diff --git a/packages/integration/src/github/GithubCredentialsProvider.ts b/packages/integration/src/github/GithubCredentialsProvider.ts index 3156488ba7..62c7cd7a57 100644 --- a/packages/integration/src/github/GithubCredentialsProvider.ts +++ b/packages/integration/src/github/GithubCredentialsProvider.ts @@ -64,12 +64,14 @@ const HEADERS = { */ class GithubAppManager { private readonly appClient: Octokit; + private readonly baseUrl?: string; private readonly baseAuthConfig: { appId: number; privateKey: string }; private readonly cache = new Cache(); private readonly allowedInstallationOwners: string[] | undefined; // undefined allows all installations constructor(config: GithubAppConfig, baseUrl?: string) { this.allowedInstallationOwners = config.allowedInstallationOwners; + this.baseUrl = baseUrl; this.baseAuthConfig = { appId: config.appId, privateKey: config.privateKey, @@ -108,6 +110,7 @@ class GithubAppManager { }); if (repo && result.data.repository_selection === 'selected') { const installationClient = new Octokit({ + baseUrl: this.baseUrl, auth: result.data.token, }); const repos = await installationClient.paginate(