feat: Okta(SCIM2.0) -> Attributes Sync and Group Option support (#17805)

This commit is contained in:
Hariom Balhara authored and GitHub committed 2024-12-06 15:17:50 +05:30
1 parent d5ef3e1d72
commit 7e76770ba6
46 files changed
+3688 -307

No files matched your search

+17 -3
View File
@@ -5,19 +5,27 @@ import handleGroupEvents from "@calcom/features/ee/dsync/lib/handleGroupEvents";
import handleUserEvents from "@calcom/features/ee/dsync/lib/handleUserEvents";
import jackson from "@calcom/features/ee/sso/lib/jackson";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import prisma from "@calcom/prisma";
const log = logger.getSubLogger({ prefix: ["[scim]"] });
// This is the handler for the SCIM API requests
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const log = logger.getSubLogger({ prefix: ["[scim]"] });
const { dsyncController } = await jackson();
log.debug("Request from SCIM", {
method: req.method,
url: req.url,
headers: req.headers,
query: req.query,
body: req.body,
cookies: req.cookies,
});
const { method, query, body } = req;
const [directoryId, path, resourceId] = query.directory as string[];
let responseBody: object | undefined = undefined;
if (body) {
try {
responseBody = JSON.parse(body);
@@ -43,6 +51,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const { status, data } = await dsyncController.requests.handle(request, handleEvents);
log.debug("Response to SCIM", {
status,
data,
});
res.status(status).json(data);
}
@@ -55,6 +68,7 @@ export const extractAuthToken = (req: NextApiRequest): string | null => {
// Handle the SCIM events
const handleEvents = async (event: DirectorySyncEvent) => {
log.debug("handleEvents", safeStringify(event));
const dSyncData = await prisma.dSyncData.findFirst({
where: {
directoryId: event.directory_id,
@@ -2834,5 +2834,9 @@
"multi_select": "Multi Select",
"group_meeting": "Group Meeting",
"salesforce_ignore_guests": "Do not create new records for guests added to the booking",
"lock_attribute_for_assignment": "Lock for assignment",
"lock_attribute_for_assignment_description": "Locking would only allow assignments from Directory Sync",
"attribute_edited_successfully": "Attribute edited successfully",
"new_group_option": "New group option",
"ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"
}
+4 -4
View File
@@ -91,7 +91,7 @@ describe("generate Csv for Org Users Table @test", () => {
{
...mockUser,
teams: [{ id: 1, name: "Team1", slug: "team1" }],
attributes: [{ id: "1", attributeId: "attr1", value: "value1", slug: "slug1" }],
attributes: [{ id: "1", attributeId: "attr1", value: "value1", slug: "slug1", contains: [] }],
},
];
@@ -115,8 +115,8 @@ describe("generate Csv for Org Users Table @test", () => {
...mockUser,
teams: [{ id: 1, name: "Team1", slug: "team1" }],
attributes: [
{ id: "1", attributeId: "attr1", value: "value1", slug: "slug1" },
{ id: "2", attributeId: "attr1", value: "value2", slug: "slug1" },
{ id: "1", attributeId: "attr1", value: "value1", slug: "slug1", contains: [] },
{ id: "2", attributeId: "attr1", value: "value2", slug: "slug1", contains: [] },
],
},
];
@@ -166,7 +166,7 @@ describe("generate Csv for Org Users Table @test", () => {
{
...mockUser,
teams: [{ id: 1, name: "Team,1", slug: "team1" }],
attributes: [{ id: "1", attributeId: "attr1", value: "value,1", slug: "slug1" }],
attributes: [{ id: "1", attributeId: "attr1", value: "value,1", slug: "slug1", contains: [] }],
},
];