changing to using the installation owner over id

Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
Brian Fletcher
2021-07-14 08:52:03 +01:00
parent 5fa0c32bff
commit beb1d7812c
2 changed files with 9 additions and 9 deletions
@@ -68,10 +68,10 @@ class GithubAppManager {
private readonly baseAuthConfig: { appId: number; privateKey: string };
private installations?: RestEndpointMethodTypes['apps']['listInstallations']['response'];
private readonly cache = new Cache();
private readonly allowedInstallations: number[] | undefined; // undefined allows all installations
private readonly allowedInstallationOwners: string[] | undefined; // undefined allows all installations
constructor(config: GithubAppConfig, baseUrl?: string) {
this.allowedInstallations = config.allowedInstallations;
this.allowedInstallationOwners = config.allowedInstallationOwners;
this.baseAuthConfig = {
appId: config.appId,
privateKey: config.privateKey,
@@ -93,8 +93,8 @@ class GithubAppManager {
suspended,
repositorySelection,
} = await this.getInstallationData(owner);
if (this.allowedInstallations) {
if (!this.allowedInstallations?.includes(installationId)) {
if (this.allowedInstallationOwners) {
if (!this.allowedInstallationOwners?.includes(owner)) {
throw new Error(
`The GitHub application for ${[owner, repo]
.filter(Boolean)
+5 -5
View File
@@ -94,9 +94,9 @@ export type GithubAppConfig = {
*/
clientSecret: string;
/**
* List of installations allowed to be used by this backstage https://github.com/app/installations/$InstallationId
* List of installation owners allowed to be used by this backstage https://github.com/app/installations/$InstallationId
*/
allowedInstallations?: number[];
allowedInstallationOwners?: string[];
};
/**
@@ -117,9 +117,9 @@ export function readGitHubIntegrationConfig(
clientSecret: c.getString('clientSecret'),
webhookSecret: c.getString('webhookSecret'),
privateKey: c.getString('privateKey'),
allowedInstallations: c
.getOptionalStringArray('allowedInstallations')
?.map(allowedInstallation => Number(allowedInstallation)),
allowedInstallationOwners: c.getOptionalStringArray(
'allowedInstallationOwners',
),
}));
if (!isValidHost(host)) {