Use instance URL for OAuth callback (#3560)

Use editor URL instead of webhook url for oauth connections
This commit is contained in:
pemontto 2022-08-29 06:53:57 -04:00 committed by GitHub
parent 3ae6450f0b
commit ff31b961b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,7 +18,7 @@ import {
import { resolve as pathResolve } from 'path';
import querystring from 'querystring';
import { Db, ICredentialsDb, ResponseHelper, WebhookHelpers } from '..';
import { Db, ICredentialsDb, ResponseHelper } from '..';
import { RESPONSE_ERROR_MESSAGES } from '../constants';
import {
CredentialsHelper,
@ -29,6 +29,7 @@ import { getLogger } from '../Logger';
import { OAuthRequest } from '../requests';
import { externalHooks } from '../Server';
import config from '../../config';
import { getInstanceBaseUrl } from '../UserManagement/UserManagementHelper';
export const oauth2CredentialController = express.Router();
@ -109,7 +110,7 @@ oauth2CredentialController.get(
clientSecret: get(oauthCredentials, 'clientSecret', '') as string,
accessTokenUri: get(oauthCredentials, 'accessTokenUrl', '') as string,
authorizationUri: get(oauthCredentials, 'authUrl', '') as string,
redirectUri: `${WebhookHelpers.getWebhookBaseUrl()}${restEndpoint}/oauth2-credential/callback`,
redirectUri: `${getInstanceBaseUrl()}${restEndpoint}/oauth2-credential/callback`,
scopes: split(get(oauthCredentials, 'scope', 'openid,') as string, ','),
state: stateEncodedStr,
};
@ -265,7 +266,7 @@ oauth2CredentialController.get(
clientSecret: get(oauthCredentials, 'clientSecret', '') as string | undefined,
accessTokenUri: get(oauthCredentials, 'accessTokenUrl', '') as string,
authorizationUri: get(oauthCredentials, 'authUrl', '') as string,
redirectUri: `${WebhookHelpers.getWebhookBaseUrl()}${restEndpoint}/oauth2-credential/callback`,
redirectUri: `${getInstanceBaseUrl()}${restEndpoint}/oauth2-credential/callback`,
scopes: split(get(oauthCredentials, 'scope', 'openid,') as string, ','),
};