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 Respuesta
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
respondido hace 5 horas

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas