feat: SSO for orgs (#13794)

* WIP

Adds the capability to add SSO setup in orgs
if you are an Admin or an Owner of the org

* remove sso setup from teams

* allows account creation on first login

* auto-add on login and dsync fixes

* allow SP & idP initiated login for SAML

* revert change to checkIfUserShouldbelongToOrg

* fixes SP initiated Login for first time

* removed stale comment

* code improvement

* --

* minor fixes

* more fix

* add description for non-admin sso settings page
This commit is contained in:
Syed Ali Shahbaz authored and GitHub committed 2024-03-26 11:11:51 +00:00
1 parent 452ea6a993
commit fd91c5da79
9 files changed
+206 -52

No files matched your search

@@ -4,7 +4,7 @@ import jackson from "@calcom/features/ee/sso/lib/jackson";
import { createAProfileForAnExistingUser } from "@calcom/lib/createAProfileForAnExistingUser";
import { getTranslation } from "@calcom/lib/server/i18n";
import prisma from "@calcom/prisma";
import { MembershipRole } from "@calcom/prisma/enums";
import { IdentityProvider, MembershipRole } from "@calcom/prisma/enums";
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
import {
getTeamOrThrow,
@@ -96,10 +96,13 @@ const handleGroupEvents = async (event: DirectorySyncEvent, organizationId: numb
// For each team linked to the dsync group name provision members
for (const group of groupNames) {
if (newUserEmails.length) {
const newUsers = await createUsersAndConnectToOrg({
const createUsersAndConnectToOrgProps = {
emailsToCreate: newUserEmails,
org,
});
organizationId: org.id,
identityProvider: IdentityProvider.CAL,
identityProviderId: null,
};
const newUsers = await createUsersAndConnectToOrg(createUsersAndConnectToOrgProps);
await prisma.membership.createMany({
data: newUsers.map((user) => ({
userId: user.id,