CDK UserpoolClient refreshTokenValidity duration fails to synthesize correctly

0
new UserPoolClient(this, 'Client', {
  idTokenValidity: Duration.hours(2),
  accessTokenValidity: Duration.hours(2),
  // CDK BUG! sets to 1 minute which is error
  refreshTokenValidity: Duration.hours(12),

is synthesized as:

      TokenValidityUnits:
        AccessToken: minutes
        IdToken: minutes
        RefreshToken: minutes

      RefreshTokenValidity: 1    // <- WRONG!
      IdTokenValidity: 120
      AccessTokenValidity: 120
1 個回答
0

In order to define the Cognito UserPool client, you can refer to the addClient function of the UserPool construct in CDK and then define the refreshTokenValidity duration to correctly synthesize the construct to the corresponding CloudFormation resource

const pool = new cognito.UserPool(this, 'Pool');
    const provider = new cognito.UserPoolIdentityProviderAmazon(this, 'Amazon', {
      userPool: pool,
      clientId: 'amzn-client-id',
      clientSecret: 'amzn-client-secret',
    });

const client = pool.addClient('app-client', {
      refreshTokenValidity: cdk.Duration.hours(12),
      idTokenValidity: cdk.Duration.hours(2),
      accessTokenValidity:cdk.Duration.hours(2),
      supportedIdentityProviders: [
        cognito.UserPoolClientIdentityProvider.AMAZON,
      ],
    });

client.node.addDependency(provider);
profile pictureAWS
已回答 13 小時前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南