diff --git a/.version b/.version index acbef76955..bf29619fd7 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -2.22.2 +2.22.3 diff --git a/frontend/.version b/frontend/.version index acbef76955..bf29619fd7 100644 --- a/frontend/.version +++ b/frontend/.version @@ -1 +1 @@ -2.22.2 +2.22.3 diff --git a/plugins/packages/common/lib/oauth.ts b/plugins/packages/common/lib/oauth.ts index 9f5889630f..7d50d92cd4 100644 --- a/plugins/packages/common/lib/oauth.ts +++ b/plugins/packages/common/lib/oauth.ts @@ -124,9 +124,12 @@ function validateAndMaybeSetOAuthHeaders(sourceOptions, context, headers): Query export function getAuthUrl(sourceOptions: any): string { const customQueryParams = sanitizeCustomParams(sourceOptions['custom_query_params']); - const tooljetHost = process.env.TOOLJET_HOST; + const host = process.env.TOOLJET_HOST; + const subpath = process.env.SUB_PATH; + const fullUrl = `${host}${subpath ? subpath : '/'}`; + const authUrl = new URL( - `${sourceOptions['auth_url']}?response_type=code&client_id=${sourceOptions['client_id']}&redirect_uri=${tooljetHost}/oauth2/authorize&scope=${sourceOptions['scopes']}` + `${sourceOptions['auth_url']}?response_type=code&client_id=${sourceOptions['client_id']}&redirect_uri=${fullUrl}oauth2/authorize&scope=${sourceOptions['scopes']}` ); Object.entries(customQueryParams).map(([key, value]) => authUrl.searchParams.append(key, value)); return authUrl.toString(); diff --git a/plugins/packages/googlesheets/lib/index.ts b/plugins/packages/googlesheets/lib/index.ts index 604acaf63c..02cb25be4c 100644 --- a/plugins/packages/googlesheets/lib/index.ts +++ b/plugins/packages/googlesheets/lib/index.ts @@ -5,7 +5,9 @@ import { SourceOptions, QueryOptions } from './types'; export default class GooglesheetsQueryService implements QueryService { authUrl(): string { - const tooljetHost = process.env.TOOLJET_HOST; + const host = process.env.TOOLJET_HOST; + const subpath = process.env.SUB_PATH; + const fullUrl = `${host}${subpath ? subpath : '/'}`; const clientId = process.env.GOOGLE_CLIENT_ID; const clientSecret = process.env.GOOGLE_CLIENT_SECRET; @@ -16,7 +18,7 @@ export default class GooglesheetsQueryService implements QueryService { return ( 'https://accounts.google.com/o/oauth2/v2/auth' + `?response_type=code&client_id=${clientId}` + - `&redirect_uri=${tooljetHost}/oauth2/authorize` + `&redirect_uri=${fullUrl}oauth2/authorize` ); } @@ -24,8 +26,10 @@ export default class GooglesheetsQueryService implements QueryService { const accessTokenUrl = 'https://oauth2.googleapis.com/token'; const clientId = process.env.GOOGLE_CLIENT_ID; const clientSecret = process.env.GOOGLE_CLIENT_SECRET; - const tooljetHost = process.env.TOOLJET_HOST; - const redirectUri = `${tooljetHost}/oauth2/authorize`; + const host = process.env.TOOLJET_HOST; + const subpath = process.env.SUB_PATH; + const fullUrl = `${host}${subpath ? subpath : '/'}`; + const redirectUri = `${fullUrl}oauth2/authorize`; const grantType = 'authorization_code'; const customParams = { prompt: 'consent', access_type: 'offline' }; diff --git a/plugins/packages/slack/lib/index.ts b/plugins/packages/slack/lib/index.ts index ae70ccb070..92cc027efb 100644 --- a/plugins/packages/slack/lib/index.ts +++ b/plugins/packages/slack/lib/index.ts @@ -5,16 +5,20 @@ import { SourceOptions, QueryOptions } from './types'; export default class SlackQueryService implements QueryService { authUrl(): string { const clientId = process.env.SLACK_CLIENT_ID; - const tooljetHost = process.env.TOOLJET_HOST; - return `https://slack.com/oauth/v2/authorize?response_type=code&client_id=${clientId}&redirect_uri=${tooljetHost}/oauth2/authorize`; + const host = process.env.TOOLJET_HOST; + const subpath = process.env.SUB_PATH; + const fullUrl = `${host}${subpath ? subpath : '/'}`; + return `https://slack.com/oauth/v2/authorize?response_type=code&client_id=${clientId}&redirect_uri=${fullUrl}oauth2/authorize`; } async accessDetailsFrom(authCode: string): Promise { const accessTokenUrl = 'https://slack.com/api/oauth.v2.access'; const clientId = process.env.SLACK_CLIENT_ID; const clientSecret = process.env.SLACK_CLIENT_SECRET; - const tooljetHost = process.env.TOOLJET_HOST; - const redirectUri = `${tooljetHost}/oauth2/authorize`; + const host = process.env.TOOLJET_HOST; + const subpath = process.env.SUB_PATH; + const fullUrl = `${host}${subpath ? subpath : '/'}`; + const redirectUri = `${fullUrl}oauth2/authorize`; const body = `code=${authCode}&client_id=${clientId}&client_secret=${clientSecret}&redirect_uri=${redirectUri}`; diff --git a/plugins/packages/zendesk/lib/index.ts b/plugins/packages/zendesk/lib/index.ts index 0a029244d6..c6de55ca10 100644 --- a/plugins/packages/zendesk/lib/index.ts +++ b/plugins/packages/zendesk/lib/index.ts @@ -29,8 +29,10 @@ export default class Zendesk implements QueryService { const { clientId, clientSecret, subdomain, scope } = this.sanitizeOptions(options); const accessTokenUrl = `https://${subdomain}.zendesk.com/oauth/tokens`; - const tooljetHost = process.env.TOOLJET_HOST; - const redirectUri = `${tooljetHost}/oauth2/authorize`; + const host = process.env.TOOLJET_HOST; + const subpath = process.env.SUB_PATH; + const fullUrl = `${host}${subpath ? subpath : '/'}`; + const redirectUri = `${fullUrl}oauth2/authorize`; const grantType = 'authorization_code'; const data = { diff --git a/server/.version b/server/.version index acbef76955..bf29619fd7 100644 --- a/server/.version +++ b/server/.version @@ -1 +1 @@ -2.22.2 +2.22.3