From 0e76e264e9bec1df68a73b75b6d8d361418893d1 Mon Sep 17 00:00:00 2001 From: Iain Billett Date: Tue, 18 Jan 2022 18:30:27 +0000 Subject: [PATCH] Return undefined rather than an empty string Signed-off-by: Iain Billett --- .changeset/chatty-pens-try.md | 2 +- .../src/github/SingleInstanceGithubCredentialsProvider.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.changeset/chatty-pens-try.md b/.changeset/chatty-pens-try.md index e8b50bf8f2..1c92bb82cb 100644 --- a/.changeset/chatty-pens-try.md +++ b/.changeset/chatty-pens-try.md @@ -2,5 +2,5 @@ '@backstage/integration': patch --- -Return an empty token rather than fail where the owner is not in the allowed installation owners +Do not return a token rather than fail where the owner is not in the allowed installation owners for a GitHub app. This allows anonymous access to public files in the organisation. diff --git a/packages/integration/src/github/SingleInstanceGithubCredentialsProvider.ts b/packages/integration/src/github/SingleInstanceGithubCredentialsProvider.ts index b3fd26cddf..bfc360cbe2 100644 --- a/packages/integration/src/github/SingleInstanceGithubCredentialsProvider.ts +++ b/packages/integration/src/github/SingleInstanceGithubCredentialsProvider.ts @@ -92,11 +92,11 @@ class GithubAppManager { async getInstallationCredentials( owner: string, repo?: string, - ): Promise<{ accessToken: string }> { + ): Promise<{ accessToken: string | undefined }> { const { installationId, suspended } = await this.getInstallationData(owner); if (this.allowedInstallationOwners) { if (!this.allowedInstallationOwners?.includes(owner)) { - return { accessToken: '' }; // An empty token allows anonymous access to public repos + return { accessToken: undefined }; // An empty token allows anonymous access to public repos } } if (suspended) {