mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 13:22:08 +00:00
Merge pull request #2667 from scott-ray-wilson/oidc-default-org-slug
Feature: OIDC Default Org
This commit is contained in:
@@ -29,6 +29,8 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
|
||||
}).extend({
|
||||
isMigrationModeOn: z.boolean(),
|
||||
defaultAuthOrgSlug: z.string().nullable(),
|
||||
defaultAuthOrgAuthEnforced: z.boolean().nullish(),
|
||||
defaultAuthOrgAuthMethod: z.string().nullish(),
|
||||
isSecretScanningDisabled: z.boolean()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -291,7 +291,7 @@ export const orgServiceFactory = ({
|
||||
}
|
||||
|
||||
if (authEnforced !== undefined) {
|
||||
if (!plan?.samlSSO || !plan.oidcSSO)
|
||||
if (!plan?.samlSSO && !plan.oidcSSO)
|
||||
throw new BadRequestError({
|
||||
message: "Failed to enforce/un-enforce SSO due to plan restriction. Upgrade plan to enforce/un-enforce SSO."
|
||||
});
|
||||
|
||||
@@ -14,9 +14,31 @@ export const superAdminDALFactory = (db: TDbClient) => {
|
||||
const config = await (tx || db)(TableName.SuperAdmin)
|
||||
.where(`${TableName.SuperAdmin}.id`, id)
|
||||
.leftJoin(TableName.Organization, `${TableName.SuperAdmin}.defaultAuthOrgId`, `${TableName.Organization}.id`)
|
||||
.leftJoin(TableName.SamlConfig, (qb) => {
|
||||
qb.on(`${TableName.SamlConfig}.orgId`, "=", `${TableName.Organization}.id`).andOn(
|
||||
`${TableName.SamlConfig}.isActive`,
|
||||
"=",
|
||||
db.raw("true")
|
||||
);
|
||||
})
|
||||
.leftJoin(TableName.OidcConfig, (qb) => {
|
||||
qb.on(`${TableName.OidcConfig}.orgId`, "=", `${TableName.Organization}.id`).andOn(
|
||||
`${TableName.OidcConfig}.isActive`,
|
||||
"=",
|
||||
db.raw("true")
|
||||
);
|
||||
})
|
||||
.select(
|
||||
db.ref("*").withSchema(TableName.SuperAdmin) as unknown as keyof TSuperAdmin,
|
||||
db.ref("slug").withSchema(TableName.Organization).as("defaultAuthOrgSlug")
|
||||
db.ref("slug").withSchema(TableName.Organization).as("defaultAuthOrgSlug"),
|
||||
db.ref("authEnforced").withSchema(TableName.Organization).as("defaultAuthOrgAuthEnforced"),
|
||||
db.raw(`
|
||||
CASE
|
||||
WHEN ${TableName.SamlConfig}."orgId" IS NOT NULL THEN 'saml'
|
||||
WHEN ${TableName.OidcConfig}."orgId" IS NOT NULL THEN 'oidc'
|
||||
ELSE NULL
|
||||
END as "defaultAuthOrgAuthMethod"
|
||||
`)
|
||||
)
|
||||
.first();
|
||||
|
||||
@@ -27,7 +49,11 @@ export const superAdminDALFactory = (db: TDbClient) => {
|
||||
return {
|
||||
...config,
|
||||
defaultAuthOrgSlug: config?.defaultAuthOrgSlug || null
|
||||
} as TSuperAdmin & { defaultAuthOrgSlug: string | null };
|
||||
} as TSuperAdmin & {
|
||||
defaultAuthOrgSlug: string | null;
|
||||
defaultAuthOrgAuthEnforced?: boolean | null;
|
||||
defaultAuthOrgAuthMethod?: string | null;
|
||||
};
|
||||
};
|
||||
|
||||
const updateById = async (id: string, data: TSuperAdminUpdate, tx?: Knex) => {
|
||||
|
||||
@@ -29,7 +29,13 @@ type TSuperAdminServiceFactoryDep = {
|
||||
export type TSuperAdminServiceFactory = ReturnType<typeof superAdminServiceFactory>;
|
||||
|
||||
// eslint-disable-next-line
|
||||
export let getServerCfg: () => Promise<TSuperAdmin & { defaultAuthOrgSlug: string | null }>;
|
||||
export let getServerCfg: () => Promise<
|
||||
TSuperAdmin & {
|
||||
defaultAuthOrgSlug: string | null;
|
||||
defaultAuthOrgAuthEnforced?: boolean | null;
|
||||
defaultAuthOrgAuthMethod?: string | null;
|
||||
}
|
||||
>;
|
||||
|
||||
const ADMIN_CONFIG_KEY = "infisical-admin-cfg";
|
||||
const ADMIN_CONFIG_KEY_EXP = 60; // 60s
|
||||
|
||||
Reference in New Issue
Block a user