Class AuthenticateCognitoAction
A Listener Action to authenticate with Cognito.
Implements
Inherited Members
Namespace: Amazon.CDK.AWS.ElasticLoadBalancingV2.Actions
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class AuthenticateCognitoAction : ListenerAction, IListenerAction
Syntax (vb)
Public Class AuthenticateCognitoAction
Inherits ListenerAction
Implements IListenerAction
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.CertificateManager;
Vpc vpc;
Certificate certificate;
var lb = new ApplicationLoadBalancer(this, "LB", new ApplicationLoadBalancerProps {
Vpc = vpc,
InternetFacing = true
});
var userPool = new UserPool(this, "UserPool");
var userPoolClient = new UserPoolClient(this, "Client", new UserPoolClientProps {
UserPool = userPool,
// Required minimal configuration for use with an ELB
GenerateSecret = true,
AuthFlows = new AuthFlow {
UserPassword = true
},
OAuth = new OAuthSettings {
Flows = new OAuthFlows {
AuthorizationCodeGrant = true
},
Scopes = new [] { OAuthScope.EMAIL },
CallbackUrls = new [] { $"https://{lb.loadBalancerDnsName}/oauth2/idpresponse" }
}
});
var cfnClient = (CfnUserPoolClient)userPoolClient.Node.DefaultChild;
cfnClient.AddPropertyOverride("RefreshTokenValidity", 1);
cfnClient.AddPropertyOverride("SupportedIdentityProviders", new [] { "COGNITO" });
var userPoolDomain = new UserPoolDomain(this, "Domain", new UserPoolDomainProps {
UserPool = userPool,
CognitoDomain = new CognitoDomainOptions {
DomainPrefix = "test-cdk-prefix"
}
});
lb.AddListener("Listener", new BaseApplicationListenerProps {
Port = 443,
Certificates = new [] { certificate },
DefaultAction = new AuthenticateCognitoAction(new AuthenticateCognitoActionProps {
UserPool = userPool,
UserPoolClient = userPoolClient,
UserPoolDomain = userPoolDomain,
Next = ListenerAction.FixedResponse(200, new FixedResponseOptions {
ContentType = "text/plain",
MessageBody = "Authenticated"
})
})
});
new CfnOutput(this, "DNS", new CfnOutputProps {
Value = lb.LoadBalancerDnsName
});
Synopsis
Constructors
AuthenticateCognitoAction(IAuthenticateCognitoActionProps) | Authenticate using an identity provide (IdP) that is compliant with OpenID Connect (OIDC). |
AuthenticateCognitoAction(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
AuthenticateCognitoAction(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Methods
Bind(Construct, IApplicationListener, IConstruct) | Called when the action is being used in a listener. |
Constructors
AuthenticateCognitoAction(IAuthenticateCognitoActionProps)
Authenticate using an identity provide (IdP) that is compliant with OpenID Connect (OIDC).
public AuthenticateCognitoAction(IAuthenticateCognitoActionProps options)
Parameters
- options IAuthenticateCognitoActionProps
AuthenticateCognitoAction(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected AuthenticateCognitoAction(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
AuthenticateCognitoAction(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected AuthenticateCognitoAction(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Methods
Bind(Construct, IApplicationListener, IConstruct)
Called when the action is being used in a listener.
public override void Bind(Construct scope, IApplicationListener listener, IConstruct associatingConstruct = null)
Parameters
- scope Constructs.Construct
- listener IApplicationListener
- associatingConstruct Constructs.IConstruct