Skip to content

Enterprise SCIM Component

The Enterprise SCIM Component can be used to assist in creating, maintaining, and deleting a SCIM client for your customers.

  1. Install shadcn in your application.

  2. Install the component.

    Terminal window
    npx shadcn@latest add https://components.propelauth.com/r/enterprise-scim.json

The URL where you handle SCIM requests. See here for more information.

Includes four methods to be used to fetch, create, edit, and delete SCIM connections in your backend. See below for an example.

onGenerate (apiKey: string) => void (optional)

Section titled “onGenerate (apiKey: string) => void (optional)”

Callback when a new SCIM connection is generated.

onReset (apiKey: string) => void (optional)

Section titled “onReset (apiKey: string) => void (optional)”

Callback when a SCIM API Key is reset.

Callback when a SCIM connection is deleted.

import ScimSetup from '@/components/scim/scim-setup';
import type { ScimApi } from '@/lib/scim/scim-types';
const api: ScimApi = {
async get() {
const r = await fetch(`/api/setup/scim`);
return { ok: true, data: await r.json() };
},
async create(body) {
const r = await fetch(`/api/setup/scim`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
return { ok: true, data: await r.json() };
},
async reset(body) {
const r = await fetch(`/api/setup/sso`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
return { ok: true, data: await r.json() };
},
async remove() {
const r = await fetch(`/api/setup/sso`, { method: "DELETE" },
);
return await r.json();
},
};
export default function Page() {
return (
<ScimSetup
scimEndpointUrl="https://api.example.com/scim"
api={api}
onGenerate={(apiKey) => console.log('Generated:', apiKey)}
onReset={(apiKey) => console.log('Reset:', apiKey)}
onDelete={() => console.log('Deleted')}
/>
);
}

It is required to build four routes in your backend to use the SsoSetup component - each corresponding with one of the three methods included in the api argument detailed above.

Use the Fetch SCIM Connection API to check if the customer has a connection.

router.get("/api/setup/scim", async (_req: Request, res: Response) => {
const result = await client.scim.management.fetchScimConnection({
customerId: "{your_id_for_your_customer}",
});
if (result.ok) {
const response = {
hasApiKey: true,
expiresAt: result.scimApiKeyValidUntil,
};
res.json(response);
} else {
const response = {
hasApiKey: false
};
res.json(response);
}
});

Creates a SCIM connection using the expiresAt property sent from the frontend component.

router.post("/api/setup/scim", async (req: Request, res: Response) => {
const createResult = await client.scim.management.createScimConnection({
customerId: "{your_id_for_your_customer}",
scimApiKeyExpiration: req.body.expiresAt,
});
if (result.ok) {
const response = {
scimApiKey: createResult.data.scimApiKey,
};
res.json(response);
} else {
res.status(400).json({ error: result.error });
}
});

Resets the SCIM API Key using the expiresAt property sent from the frontend component.

router.put("/api/setup/scim", async (req: Request, res: Response) => {
const createResult = await client.scim.management.resetScimApiKey({
customerId: "{your_id_for_your_customer}",
scimApiKeyExpiration: req.body.expiresAt,
});
if (result.ok) {
const response = {
scimApiKey: createResult.data.scimApiKey,
};
res.json(response);
} else {
res.status(400).json({ error: result.error });
}
});

Deletes a SCIM connection.

router.delete("/api/setup/scim", async (_req: Request, res: Response) => {
const deleteResult = await client.sso.management.deleteScimConnection({
customerId: "{your_id_for_your_customer}",
});
if (deleteResult.ok) {
res.json({ message: "SCIM connection deleted successfully" });
} else {
res.status(404).json({ error: result.error });
}
});