Add ability to override github app callback url

By default, the github app provider redirects back to the base url.
This change allows a user to override the GitHub App url using the config field `customCallbackUrl`.

It will look like this in the configuration:
```
auth:
  providers:
    github:
      development:
        clientId: SUPER ID
        clientSecret: SUPER SECRET
        customCallbackUrl: https://some-url.com/callback
```

Signed-off-by: Nicolas Arnold <nic@roadie.io>
This commit is contained in:
Nicolas Arnold
2021-09-27 10:40:44 +01:00
parent a343837854
commit 88622e6422
2 changed files with 10 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-auth-backend': patch
---
Allow users to override callback url of Github provider
@@ -223,6 +223,9 @@ export const createGithubProvider = (
const enterpriseInstanceUrl = envConfig.getOptionalString(
'enterpriseInstanceUrl',
);
const customCallbackUrl = envConfig.getOptionalString(
'customCallbackUrl',
);
const authorizationUrl = enterpriseInstanceUrl
? `${enterpriseInstanceUrl}/login/oauth/authorize`
: undefined;
@@ -232,7 +235,8 @@ export const createGithubProvider = (
const userProfileUrl = enterpriseInstanceUrl
? `${enterpriseInstanceUrl}/api/v3/user`
: undefined;
const callbackUrl = `${globalConfig.baseUrl}/${providerId}/handler/frame`;
const callbackUrl = customCallbackUrl ||
`${globalConfig.baseUrl}/${providerId}/handler/frame`;
const catalogIdentityClient = new CatalogIdentityClient({
catalogApi,