use env platform URL for datasource auth to prevent tenant overrides
This commit is contained in:
parent
18ea87e5e3
commit
08a3ae0e7c
|
@ -4,6 +4,7 @@ const google = require("../google")
|
||||||
const { Configs, Cookies } = require("../../../constants")
|
const { Configs, Cookies } = require("../../../constants")
|
||||||
const { clearCookie, getCookie } = require("../../../utils")
|
const { clearCookie, getCookie } = require("../../../utils")
|
||||||
const { getDB } = require("../../../db")
|
const { getDB } = require("../../../db")
|
||||||
|
const environment = require("../../../environment")
|
||||||
|
|
||||||
async function preAuth(passport, ctx, next) {
|
async function preAuth(passport, ctx, next) {
|
||||||
const db = getGlobalDB()
|
const db = getGlobalDB()
|
||||||
|
@ -12,10 +13,7 @@ async function preAuth(passport, ctx, next) {
|
||||||
type: Configs.GOOGLE,
|
type: Configs.GOOGLE,
|
||||||
workspace: ctx.query.workspace,
|
workspace: ctx.query.workspace,
|
||||||
})
|
})
|
||||||
const publicConfig = await getScopedConfig(db, {
|
let callbackUrl = `${environment.PLATFORM_URL}/api/global/auth/datasource/google/callback`
|
||||||
type: Configs.SETTINGS,
|
|
||||||
})
|
|
||||||
let callbackUrl = `${publicConfig.platformUrl}/api/global/auth/datasource/google/callback`
|
|
||||||
const strategy = await google.strategyFactory(config, callbackUrl)
|
const strategy = await google.strategyFactory(config, callbackUrl)
|
||||||
|
|
||||||
if (!ctx.query.appId || !ctx.query.datasourceId) {
|
if (!ctx.query.appId || !ctx.query.datasourceId) {
|
||||||
|
@ -37,11 +35,7 @@ async function postAuth(passport, ctx, next) {
|
||||||
workspace: ctx.query.workspace,
|
workspace: ctx.query.workspace,
|
||||||
})
|
})
|
||||||
|
|
||||||
const publicConfig = await getScopedConfig(db, {
|
let callbackUrl = `${environment.PLATFORM_URL}/api/global/auth/datasource/google/callback`
|
||||||
type: Configs.SETTINGS,
|
|
||||||
})
|
|
||||||
|
|
||||||
let callbackUrl = `${publicConfig.platformUrl}/api/global/auth/datasource/google/callback`
|
|
||||||
const strategy = await google.strategyFactory(
|
const strategy = await google.strategyFactory(
|
||||||
config,
|
config,
|
||||||
callbackUrl,
|
callbackUrl,
|
||||||
|
|
|
@ -80,6 +80,11 @@ router
|
||||||
updateTenant,
|
updateTenant,
|
||||||
authController.googleAuth
|
authController.googleAuth
|
||||||
)
|
)
|
||||||
|
.get(
|
||||||
|
"/api/global/auth/:tenantId/datasource/:provider/callback",
|
||||||
|
updateTenant,
|
||||||
|
authController.datasourceAuth
|
||||||
|
)
|
||||||
.get(
|
.get(
|
||||||
"/api/global/auth/:tenantId/oidc/configs/:configId",
|
"/api/global/auth/:tenantId/oidc/configs/:configId",
|
||||||
updateTenant,
|
updateTenant,
|
||||||
|
|
Loading…
Reference in New Issue