fix(GithubCredentialsProvider): support selective app installs with GHE hosts

Signed-off-by: Phil Kuang <pkuang@factset.com>
This commit is contained in:
Phil Kuang
2021-09-22 15:43:40 -04:00
parent d4d326df17
commit d1f2118389
2 changed files with 8 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/integration': patch
---
Support selective GitHub app installation for GHE
@@ -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(