Skip to content
v2.274.0

AuthenticateCognitoActionProps Struct ​

Properties for AuthenticateCognitoAction.

Example ​

ts
import { aws_certificatemanager as acm } from 'aws-cdk-lib';

declare const vpc: ec2.Vpc;
declare const certificate: acm.Certificate;

const lb = new elbv2.ApplicationLoadBalancer(this, 'LB', {
  vpc,
  internetFacing: true,
});

const userPool = new cognito.UserPool(this, 'UserPool');
const userPoolClient = new cognito.UserPoolClient(this, 'Client', {
  userPool,

  // Required minimal configuration for use with an ELB
  generateSecret: true,
  authFlows: {
    userPassword: true,
  },
  oAuth: {
    flows: {
      authorizationCodeGrant: true,
    },
    scopes: [cognito.OAuthScope.EMAIL],
    callbackUrls: [
      `https://${lb.loadBalancerDnsName}/oauth2/idpresponse`,
    ],
  },
});
const cfnClient = userPoolClient.node.defaultChild as cognito.CfnUserPoolClient;
cfnClient.addPropertyOverride('RefreshTokenValidity', 1);
cfnClient.addPropertyOverride('SupportedIdentityProviders', ['COGNITO']);

const userPoolDomain = new cognito.UserPoolDomain(this, 'Domain', {
  userPool,
  cognitoDomain: {
    domainPrefix: 'test-cdk-prefix',
  },
});

lb.addListener('Listener', {
  port: 443,
  certificates: [certificate],
  defaultAction: new actions.AuthenticateCognitoAction({
    userPool,
    userPoolClient,
    userPoolDomain,
    next: elbv2.ListenerAction.fixedResponse(200, {
      contentType: 'text/plain',
      messageBody: 'Authenticated',
    }),
  }),
});

new CfnOutput(this, 'DNS', {
  value: lb.loadBalancerDnsName,
});

Properties ​

allowHttpsOutboundbooleanallow_https_outboundboolallowHttpsOutboundBooleanAllowHttpsOutboundboolAllowHttpsOutbound*bool= true#
Allow HTTPS outbound traffic to communicate with the IdP.

Set this property to false if the IP address used for the IdP endpoint is identifiable and you want to control outbound traffic. Then allow HTTPS outbound traffic to the IdP's IP address using the listener's connections property.

authenticationRequestExtraParams{ [key: string]: string }authentication_request_extra_paramstyping.Mapping[str, str]authenticationRequestExtraParamsMap<String, String>AuthenticationRequestExtraParamsIDictionary<string, string>AuthenticationRequestExtraParams*map[string]*string#
The query parameters (up to 10) to include in the redirect request to the authorization endpoint.

Default: No extra parameters

onUnauthenticatedRequestUnauthenticatedActionon_unauthenticated_requestUnauthenticatedActiononUnauthenticatedRequestUnauthenticatedActionOnUnauthenticatedRequestUnauthenticatedActionOnUnauthenticatedRequestUnauthenticatedAction#
The behavior if the user is not authenticated.

Default: UnauthenticatedAction.AUTHENTICATE

scopestringscopestrscopeStringScopestringScope*string= "openid"#
The set of user claims to be requested from the IdP.

To verify which scope values your IdP supports and how to separate multiple values, see the documentation for your IdP.

sessionCookieNamestringsession_cookie_namestrsessionCookieNameStringSessionCookieNamestringSessionCookieName*string= "AWSELBAuthSessionCookie"#
The name of the cookie used to maintain session information.
sessionTimeoutDurationsession_timeoutDurationsessionTimeoutDurationSessionTimeoutDurationSessionTimeoutDuration= Duration.days(7)#
The maximum duration of the authentication session.
userPoolIUserPooluser_poolIUserPooluserPoolIUserPoolUserPoolIUserPoolUserPoolIUserPoolrequired#
The Amazon Cognito user pool.
userPoolClientIUserPoolClientuser_pool_clientIUserPoolClientuserPoolClientIUserPoolClientUserPoolClientIUserPoolClientUserPoolClientIUserPoolClientrequired#
The Amazon Cognito user pool client.
userPoolDomainIUserPoolDomainuser_pool_domainIUserPoolDomainuserPoolDomainIUserPoolDomainUserPoolDomainIUserPoolDomainUserPoolDomainIUserPoolDomainrequired#
The domain prefix or fully-qualified domain name of the Amazon Cognito user pool.