mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-21 13:06:59 +02:00
fix: allow default IdP validation in global mode policies
This commit is contained in:
committed by
GitHub
parent
fec0fea766
commit
ad1c8113ea
@@ -74,13 +74,7 @@ export async function updateResourcePolicies(
|
|||||||
const [provider] = await trx
|
const [provider] = await trx
|
||||||
.select()
|
.select()
|
||||||
.from(idp)
|
.from(idp)
|
||||||
.innerJoin(idpOrg, eq(idpOrg.idpId, idp.idpId))
|
.where(eq(idp.idpId, policyData["auto-login-idp"]))
|
||||||
.where(
|
|
||||||
and(
|
|
||||||
eq(idp.idpId, policyData["auto-login-idp"]),
|
|
||||||
eq(idpOrg.orgId, orgId)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
@@ -88,6 +82,25 @@ export async function updateResourcePolicies(
|
|||||||
`Identity provider not found for policy '${policyNiceId}' in this organization`
|
`Identity provider not found for policy '${policyNiceId}' in this organization`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.env.IDENTITY_PROVIDER_MODE === "org") {
|
||||||
|
const [providerOrg] = await trx
|
||||||
|
.select()
|
||||||
|
.from(idpOrg)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(idpOrg.idpId, policyData["auto-login-idp"]),
|
||||||
|
eq(idpOrg.orgId, orgId)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!providerOrg) {
|
||||||
|
throw new Error(
|
||||||
|
`Identity provider not found for policy '${policyNiceId}' in this organization`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look up the admin role
|
// Look up the admin role
|
||||||
|
|||||||
@@ -207,8 +207,7 @@ export async function createResourcePolicy(
|
|||||||
const [provider] = await db
|
const [provider] = await db
|
||||||
.select()
|
.select()
|
||||||
.from(idp)
|
.from(idp)
|
||||||
.innerJoin(idpOrg, eq(idpOrg.idpId, idp.idpId))
|
.where(eq(idp.idpId, skipToIdpId))
|
||||||
.where(and(eq(idp.idpId, skipToIdpId), eq(idpOrg.orgId, orgId)))
|
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
@@ -219,6 +218,28 @@ export async function createResourcePolicy(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.env.IDENTITY_PROVIDER_MODE === "org") {
|
||||||
|
const [providerOrg] = await db
|
||||||
|
.select()
|
||||||
|
.from(idpOrg)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(idpOrg.idpId, skipToIdpId),
|
||||||
|
eq(idpOrg.orgId, orgId)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!providerOrg) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"Identity provider not found in this organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const adminRole = await db
|
const adminRole = await db
|
||||||
|
|||||||
@@ -107,10 +107,7 @@ export async function setResourcePolicyAccessControl(
|
|||||||
const [provider] = await db
|
const [provider] = await db
|
||||||
.select()
|
.select()
|
||||||
.from(idp)
|
.from(idp)
|
||||||
.innerJoin(idpOrg, eq(idpOrg.idpId, idp.idpId))
|
.where(eq(idp.idpId, idpId))
|
||||||
.where(
|
|
||||||
and(eq(idp.idpId, idpId), eq(idpOrg.orgId, policy.orgId))
|
|
||||||
)
|
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
@@ -121,6 +118,25 @@ export async function setResourcePolicyAccessControl(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.env.IDENTITY_PROVIDER_MODE === "org") {
|
||||||
|
const [providerOrg] = await db
|
||||||
|
.select()
|
||||||
|
.from(idpOrg)
|
||||||
|
.where(
|
||||||
|
and(eq(idpOrg.idpId, idpId), eq(idpOrg.orgId, policy.orgId))
|
||||||
|
)
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!providerOrg) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"Identity provider not found in this organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if any of the roleIds are admin roles
|
// Check if any of the roleIds are admin roles
|
||||||
|
|||||||
Reference in New Issue
Block a user