Avoid loading github installation if owner is not in allowedInstallationOwners

Signed-off-by: Alex Crome <afscrome@users.noreply.github.com>
This commit is contained in:
Alex Crome
2022-09-05 21:56:28 +01:00
parent 3420f44149
commit 17a4968d40
@@ -93,12 +93,13 @@ class GithubAppManager {
owner: string,
repo?: string,
): Promise<{ accessToken: string | undefined }> {
const { installationId, suspended } = await this.getInstallationData(owner);
if (this.allowedInstallationOwners) {
if (!this.allowedInstallationOwners?.includes(owner)) {
return { accessToken: undefined }; // An empty token allows anonymous access to public repos
}
}
const { installationId, suspended } = await this.getInstallationData(owner);
if (suspended) {
throw new Error(`The GitHub application for ${owner} is suspended`);
}