Skip to content

Enterprise SSO Component

The Enterprise SSO Component can be used to assist in collecting the necessary information from your users to setup Enterprise SSO.

  1. Install shadcn in your application.

  2. Install the component.

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

Also known as a callback URL, this is the value that your customers will be redirected to after authenticating with their IdP. This value must match the value used when Creating the OIDC Client.

Includes three methods to be used to fetch, create, and delete OIDC clients in your backend. See below for an example.

import SsoSetup from '@/components/sso/sso-setup';
import type { SsoApi } from '@/lib/sso/sso-types';
const api: SsoApi = {
async get() {
const r = await fetch(`/api/setup/sso`);
if (!r.ok) return { ok: false, error: { status: r.status, message: await r.text() } };
return { ok: true, data: await r.json() };
},
async upsert(body) {
const r = await fetch(`/api/setup/sso`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
return r.ok
? { ok: true, data: undefined }
: { ok: false, error: { status: r.status, message: await r.text() } };
},
async remove() {
const r = await fetch(`/api/setup/sso`, { method: "DELETE" },
);
return r.ok
? { ok: true, data: undefined }
: { ok: false, error: { status: r.status, message: await r.text() } };
},
};
export default function Page() {
return (
<SsoSetup
redirectUrl='http://<your-domain>/api/auth/finish-login'
api={api}
/>
);
}

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

Returns the idpInfoFromCustomer object from the Fetch OIDC Client API.

router.get("/api/setup/sso", async (_req: Request, res: Response) => {
const result = await client.sso.management.fetchOidcClient({
customerId: "{your_id_for_your_customer}",
});
if (result.ok) {
const response = {"idpInfoFromCustomer": result.idpInfoFromCustomer};
res.json(response);
} else {
res.status(404).json({ error: result.error });
}
});

Creates an OIDC client using the idpInfoFromCustomer object sent from the frontend component.

router.post("/api/setup/sso", async (req: Request, res: Response) => {
const createResult = await client.sso.management.createOidcClient({
idpInfoFromCustomer: req.body.idpInfoFromCustomer,
customerId: "{your_id_for_your_customer}",
redirectUrl: "http://<your-domain>/api/auth/finish-login"
});
if (result.ok) {
res.json({ success: true });
} else {
res.status(400).json({ error: result.error });
}
});

Deletes an OIDC client.

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