mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 02:16:34 +00:00
feature: oidc support for oidc and only display saml/oidc login if enforced
This commit is contained in:
@@ -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