diff --git a/.changeset/rotten-planes-watch.md b/.changeset/rotten-planes-watch.md new file mode 100644 index 0000000000..25aa6b83df --- /dev/null +++ b/.changeset/rotten-planes-watch.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-auth-backend': patch +--- + +Handle trailing slashes on GitHub `enterpriseInstanceUrl` settings diff --git a/plugins/auth-backend/src/providers/github/provider.ts b/plugins/auth-backend/src/providers/github/provider.ts index 29e8679fe0..c875f856b6 100644 --- a/plugins/auth-backend/src/providers/github/provider.ts +++ b/plugins/auth-backend/src/providers/github/provider.ts @@ -318,9 +318,9 @@ export const createGithubProvider = ( OAuthEnvironmentHandler.mapConfig(config, envConfig => { const clientId = envConfig.getString('clientId'); const clientSecret = envConfig.getString('clientSecret'); - const enterpriseInstanceUrl = envConfig.getOptionalString( - 'enterpriseInstanceUrl', - ); + const enterpriseInstanceUrl = envConfig + .getOptionalString('enterpriseInstanceUrl') + ?.replace(/\/$/, ''); const customCallbackUrl = envConfig.getOptionalString('callbackUrl'); const authorizationUrl = enterpriseInstanceUrl ? `${enterpriseInstanceUrl}/login/oauth/authorize`