login with idp

This commit is contained in:
peintnermax
2024-03-15 17:21:21 +01:00
parent 952a1c85be
commit 7cd59d8c6b
8 changed files with 159 additions and 17 deletions

View File

@@ -1,5 +1,31 @@
import { getLoginSettings, server } from "#/lib/zitadel";
import {
getLegalAndSupportSettings,
getLoginSettings,
server,
} from "#/lib/zitadel";
import { SignInWithIDP } from "#/ui/SignInWithIDP";
import UsernameForm from "#/ui/UsernameForm";
import {
GetActiveIdentityProvidersResponse,
IdentityProvider,
ZitadelServer,
settings,
} from "@zitadel/server";
function getIdentityProviders(
server: ZitadelServer,
orgId?: string
): Promise<IdentityProvider[] | undefined> {
const settingsService = settings.getSettings(server);
return settingsService
.getActiveIdentityProviders(
orgId ? { ctx: { orgId } } : { ctx: { instance: true } },
{}
)
.then((resp: GetActiveIdentityProvidersResponse) => {
return resp.identityProviders;
});
}
export default async function Page({
searchParams,
@@ -12,6 +38,14 @@ export default async function Page({
const submit: boolean = searchParams?.submit === "true";
const loginSettings = await getLoginSettings(server, organization);
const legal = await getLegalAndSupportSettings(server);
// TODO if org idps should be shown replace emptystring with the orgId.
const identityProviders = await getIdentityProviders(server, "");
const host = process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: "http://localhost:3000";
return (
<div className="flex flex-col items-center space-y-4">
@@ -25,6 +59,13 @@ export default async function Page({
organization={organization}
submit={submit}
/>
{legal && identityProviders && process.env.ZITADEL_API_URL && (
<SignInWithIDP
host={host}
identityProviders={identityProviders}
></SignInWithIDP>
)}
</div>
);
}