@@ -36,11 +36,15 @@ export class BackendStack extends cdk.Stack {
36
36
37
37
const domain = Utils . getEnv ( "COGNITO_DOMAIN_NAME" ) ;
38
38
const identityProviderName = Utils . getEnv ( "IDENTITY_PROVIDER_NAME" , "" ) ;
39
+ const OIDCProviderName = Utils . getEnv ( "OIDC_PROVIDER_NAME" , "" ) ;
39
40
40
41
const identityProviderMetadataURLOrFile = Utils . getEnv (
41
42
"IDENTITY_PROVIDER_METADATA" ,
42
43
""
43
44
) ;
45
+ const OIDCClientId = Utils . getEnv ( 'OIDC_CLIENT_ID' )
46
+ const OIDCClientSecret = Utils . getEnv ( 'OIDC_CLIENT_SECRET' )
47
+ const OIDCIssuerUrl = Utils . getEnv ( 'OIDC_ISSUER_URL' )
44
48
45
49
const appFrontendDeployMode = Utils . getEnv ( "APP_FRONTEND_DEPLOY_MODE" , "" ) ;
46
50
@@ -319,6 +323,28 @@ export class BackendStack extends cdk.Stack {
319
323
supportedIdentityProviders . push ( identityProviderName ) ;
320
324
}
321
325
326
+ if ( OIDCProviderName && OIDCClientId && OIDCClientSecret && OIDCIssuerUrl ) {
327
+ const oidcProvider = new cognito . UserPoolIdentityProviderOidc ( this , 'OidcProvider' , {
328
+ userPool,
329
+ name : OIDCProviderName ,
330
+ clientId : OIDCClientId ,
331
+ clientSecret : OIDCClientSecret ,
332
+ issuerUrl : OIDCIssuerUrl ,
333
+ attributeRequestMethod : cognito . OidcAttributeRequestMethod . GET ,
334
+ scopes : [ 'openid' , 'profile' , 'email' ] ,
335
+ attributeMapping : {
336
+ email : cognito . ProviderAttribute . other ( 'email' ) ,
337
+ givenName : cognito . ProviderAttribute . other ( 'given_name' ) ,
338
+ familyName : cognito . ProviderAttribute . other ( 'family_name' ) ,
339
+ custom : {
340
+ [ groupsAttributeClaimName ] : cognito . ProviderAttribute . other ( 'groups' ) ,
341
+ }
342
+ } ,
343
+ } ) ;
344
+
345
+ supportedIdentityProviders . push ( OIDCProviderName ) ;
346
+ }
347
+
322
348
// ========================================================================
323
349
// Resource: Cognito App Client
324
350
// ========================================================================
0 commit comments