Class AuthenticateCognitoAction
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.elasticloadbalancingv2.ListenerAction
software.amazon.awscdk.services.elasticloadbalancingv2.actions.AuthenticateCognitoAction
- All Implemented Interfaces:
IListenerAction,software.amazon.jsii.JsiiSerializable
@Generated(value="jsii-pacmak/1.120.0 (build 192dc88)",
date="2025-12-05T10:47:20.678Z")
@Stability(Stable)
public class AuthenticateCognitoAction
extends ListenerAction
A Listener Action to authenticate with Cognito.
Example:
import software.amazon.awscdk.services.certificatemanager.*;
Vpc vpc;
Certificate certificate;
ApplicationLoadBalancer lb = ApplicationLoadBalancer.Builder.create(this, "LB")
.vpc(vpc)
.internetFacing(true)
.build();
UserPool userPool = new UserPool(this, "UserPool");
UserPoolClient userPoolClient = UserPoolClient.Builder.create(this, "Client")
.userPool(userPool)
// Required minimal configuration for use with an ELB
.generateSecret(true)
.authFlows(AuthFlow.builder()
.userPassword(true)
.build())
.oAuth(OAuthSettings.builder()
.flows(OAuthFlows.builder()
.authorizationCodeGrant(true)
.build())
.scopes(List.of(OAuthScope.EMAIL))
.callbackUrls(List.of(String.format("https://%s/oauth2/idpresponse", lb.getLoadBalancerDnsName())))
.build())
.build();
CfnUserPoolClient cfnClient = (CfnUserPoolClient)userPoolClient.getNode().getDefaultChild();
cfnClient.addPropertyOverride("RefreshTokenValidity", 1);
cfnClient.addPropertyOverride("SupportedIdentityProviders", List.of("COGNITO"));
UserPoolDomain userPoolDomain = UserPoolDomain.Builder.create(this, "Domain")
.userPool(userPool)
.cognitoDomain(CognitoDomainOptions.builder()
.domainPrefix("test-cdk-prefix")
.build())
.build();
lb.addListener("Listener", BaseApplicationListenerProps.builder()
.port(443)
.certificates(List.of(certificate))
.defaultAction(AuthenticateCognitoAction.Builder.create()
.userPool(userPool)
.userPoolClient(userPoolClient)
.userPoolDomain(userPoolDomain)
.next(ListenerAction.fixedResponse(200, FixedResponseOptions.builder()
.contentType("text/plain")
.messageBody("Authenticated")
.build()))
.build())
.build());
CfnOutput.Builder.create(this, "DNS")
.value(lb.getLoadBalancerDnsName())
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA fluent builder forAuthenticateCognitoAction.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.elasticloadbalancingv2.IListenerAction
IListenerAction.Jsii$Default, IListenerAction.Jsii$Proxy -
Constructor Summary
ConstructorsModifierConstructorDescriptionAuthenticate using an identity provide (IdP) that is compliant with OpenID Connect (OIDC).protectedAuthenticateCognitoAction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedAuthenticateCognitoAction(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionvoidbind(software.constructs.Construct scope, IApplicationListener listener) Called when the action is being used in a listener.voidbind(software.constructs.Construct scope, IApplicationListener listener, software.constructs.IConstruct associatingConstruct) Called when the action is being used in a listener.Methods inherited from class software.amazon.awscdk.services.elasticloadbalancingv2.ListenerAction
addRuleAction, authenticateOidc, fixedResponse, fixedResponse, forward, forward, getNext, redirect, renderActions, renderRuleActions, renumber, weightedForward, weightedForwardMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
AuthenticateCognitoAction
protected AuthenticateCognitoAction(software.amazon.jsii.JsiiObjectRef objRef) -
AuthenticateCognitoAction
protected AuthenticateCognitoAction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
AuthenticateCognitoAction
@Stability(Stable) public AuthenticateCognitoAction(@NotNull AuthenticateCognitoActionProps options) Authenticate using an identity provide (IdP) that is compliant with OpenID Connect (OIDC).- Parameters:
options- This parameter is required.
-
-
Method Details
-
bind
@Stability(Stable) public void bind(@NotNull software.constructs.Construct scope, @NotNull IApplicationListener listener, @Nullable software.constructs.IConstruct associatingConstruct) Called when the action is being used in a listener.- Overrides:
bindin classListenerAction- Parameters:
scope- This parameter is required.listener- This parameter is required.associatingConstruct-
-
bind
@Stability(Stable) public void bind(@NotNull software.constructs.Construct scope, @NotNull IApplicationListener listener) Called when the action is being used in a listener.- Overrides:
bindin classListenerAction- Parameters:
scope- This parameter is required.listener- This parameter is required.
-