Merge pull request #7287 from kuangp/fix/GithubCredentialsProvider

fix(GithubCredentialsProvider): support selective app installs with GHE hosts
This commit is contained in:
Johan Haals
2021-09-24 11:11:51 +02:00
committed by GitHub
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(