@@ -36,11 +36,15 @@ export class BackendStack extends cdk.Stack {
3636
3737    const  domain  =  Utils . getEnv ( "COGNITO_DOMAIN_NAME" ) ; 
3838    const  identityProviderName  =  Utils . getEnv ( "IDENTITY_PROVIDER_NAME" ,  "" ) ; 
39+     const  OIDCProviderName  =  Utils . getEnv ( "OIDC_PROVIDER_NAME" ,  "" ) ; 
3940
4041    const  identityProviderMetadataURLOrFile  =  Utils . getEnv ( 
4142      "IDENTITY_PROVIDER_METADATA" , 
4243      "" 
4344    ) ; 
45+     const  OIDCClientId  =  Utils . getEnv ( 'OIDC_CLIENT_ID' ) 
46+     const  OIDCClientSecret  =  Utils . getEnv ( 'OIDC_CLIENT_SECRET' ) 
47+     const  OIDCIssuerUrl  =  Utils . getEnv ( 'OIDC_ISSUER_URL' ) 
4448
4549    const  appFrontendDeployMode  =  Utils . getEnv ( "APP_FRONTEND_DEPLOY_MODE" ,  "" ) ; 
4650
@@ -319,6 +323,28 @@ export class BackendStack extends cdk.Stack {
319323      supportedIdentityProviders . push ( identityProviderName ) ; 
320324    } 
321325
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+ 
322348    // ======================================================================== 
323349    // Resource: Cognito App Client 
324350    // ======================================================================== 
0 commit comments