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
답변함 3시간 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠