Skip to content

IdentityProvider

Source: src/AWS/Cognito/IdentityProvider.ts

A third-party identity provider (SAML, OIDC, or social) attached to an Amazon Cognito user pool, enabling federated sign-in through managed login.

OIDC Provider

import * as Cognito from "alchemy/AWS/Cognito";
const pool = yield* Cognito.UserPool("Users", {});
const oidc = yield* Cognito.IdentityProvider("Corporate", {
userPoolId: pool.userPoolId,
providerType: "OIDC",
providerDetails: {
client_id: "my-client-id",
client_secret: Redacted.make("my-client-secret"),
authorize_scopes: "openid email",
oidc_issuer: "https://accounts.google.com",
attributes_request_method: "GET",
},
attributeMapping: { email: "email", username: "sub" },
});

Wire the IdP to an App Client

const client = yield* Cognito.UserPoolClient("Web", {
userPoolId: pool.userPoolId,
supportedIdentityProviders: ["COGNITO", oidc.providerName],
});