fix(auth): validate IdP authority before SAML account linking (#26005)

* fix(auth): validate IdP authority before SAML account linking

Adds verification that SAML IdP is authoritative for the email domain
before allowing account conversion

* fix(auth): deny by default on missing SAML tenant + optimize membership query

 - Block account conversion when tenant is missing (deny by default)
 - Replace JOIN + ILIKE with two indexed lookups for O(1) performance

* refactor(auth): apply data minimization to security logs
This commit is contained in:
Pedro Castro authored and GitHub committed 2025-12-20 17:45:18 +00:00
1 parent a37805439b
commit 9ae2381755
7 files changed
+427 -1

No files matched your search

@@ -1,7 +1,7 @@
import type { PrismaClient } from "@calcom/prisma";
export class OrganizationSettingsRepository {
constructor(private prismaClient: PrismaClient) {}
constructor(private readonly prismaClient: PrismaClient) {}
async getEmailSettings(organizationId: number) {
return await this.prismaClient.organizationSettings.findUnique({
@@ -19,4 +19,22 @@ export class OrganizationSettingsRepository {
},
});
}
// Returns array for future multi-domain support
async getVerifiedDomains(organizationId: number): Promise<string[]> {
const settings = await this.prismaClient.organizationSettings.findUnique({
where: { organizationId },
select: {
isOrganizationVerified: true,
orgAutoAcceptEmail: true,
},
});
if (!settings?.isOrganizationVerified) {
return [];
}
const domain = settings.orgAutoAcceptEmail;
return domain ? [domain.toLowerCase()] : [];
}
}