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
已回答 1 小时前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则