Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions cdk/src/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ export class BackendStack extends cdk.Stack {

const domain = Utils.getEnv("COGNITO_DOMAIN_NAME");
const identityProviderName = Utils.getEnv("IDENTITY_PROVIDER_NAME", "");
const OIDCProviderName = Utils.getEnv("OIDC_PROVIDER_NAME", "");

const identityProviderMetadataURLOrFile = Utils.getEnv(
"IDENTITY_PROVIDER_METADATA",
""
);
const OIDCClientId = Utils.getEnv('OIDC_CLIENT_ID')
const OIDCClientSecret = Utils.getEnv('OIDC_CLIENT_SECRET')
const OIDCIssuerUrl = Utils.getEnv('OIDC_ISSUER_URL')

const appFrontendDeployMode = Utils.getEnv("APP_FRONTEND_DEPLOY_MODE", "");

Expand Down Expand Up @@ -319,6 +323,28 @@ export class BackendStack extends cdk.Stack {
supportedIdentityProviders.push(identityProviderName);
}

if (OIDCProviderName && OIDCClientId && OIDCClientSecret && OIDCIssuerUrl) {
const oidcProvider = new cognito.UserPoolIdentityProviderOidc(this, 'OidcProvider', {
userPool,
name: OIDCProviderName,
clientId: OIDCClientId,
clientSecret: OIDCClientSecret,
issuerUrl: OIDCIssuerUrl,
attributeRequestMethod: cognito.OidcAttributeRequestMethod.GET,
scopes: ['openid', 'profile', 'email'],
attributeMapping: {
email: cognito.ProviderAttribute.other('email'),
givenName: cognito.ProviderAttribute.other('given_name'),
familyName: cognito.ProviderAttribute.other('family_name'),
custom: {
[groupsAttributeClaimName]: cognito.ProviderAttribute.other('groups'),
}
},
});

supportedIdentityProviders.push(OIDCProviderName);
}

// ========================================================================
// Resource: Cognito App Client
// ========================================================================
Expand Down
12 changes: 12 additions & 0 deletions env.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export APP_URL=http://localhost:3000
## 5. optional - for IdP integration
## ====================================================================================================================

### SAML
## the name you want for the Identity Provider

# export IDENTITY_PROVIDER_NAME=IdP
Expand All @@ -64,6 +65,17 @@ export APP_URL=http://localhost:3000

# export IDENTITY_PROVIDER_METADATA=<https://example.com/metadata.xml or $(cat path/to/metadata.xml)>

### OIDC
## the name you want for the Identity Provider

# export OIDC_PROVIDER_NAME=OIDC

## the IdPs OIDC configuration settings

# export OIDC_CLIENT_ID=<client id>
# export OIDC_CLIENT_SECRET=<client secret>
# export OIDC_ISSUER_URL=<issuer url>

## ====================================================================================================================
## 6. other optional configuration
## ====================================================================================================================
Expand Down
Loading