From 88622e642252008d10b8769f7182875412b80239 Mon Sep 17 00:00:00 2001 From: Nicolas Arnold Date: Mon, 27 Sep 2021 10:40:44 +0100 Subject: [PATCH] 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 --- .changeset/pretty-feet-explode.md | 5 +++++ plugins/auth-backend/src/providers/github/provider.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/pretty-feet-explode.md diff --git a/.changeset/pretty-feet-explode.md b/.changeset/pretty-feet-explode.md new file mode 100644 index 0000000000..c5cf0beb00 --- /dev/null +++ b/.changeset/pretty-feet-explode.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-auth-backend': patch +--- + +Allow users to override callback url of Github provider diff --git a/plugins/auth-backend/src/providers/github/provider.ts b/plugins/auth-backend/src/providers/github/provider.ts index b6b198b644..8abd4c76ea 100644 --- a/plugins/auth-backend/src/providers/github/provider.ts +++ b/plugins/auth-backend/src/providers/github/provider.ts @@ -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,