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
回答済み 4時間前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ