AuthFlow Struct
Types of authentication flow.
| Source | aws-cognito/lib/user-pool-client.ts |
|---|---|
| Type last changed |
Example
ts
const userPool = new cognito.UserPool(this, 'myuserpool', {
signInPolicy: {
allowedFirstAuthFactors: {
password: true, // password authentication must be enabled
emailOtp: true, // enables email message one-time password
smsOtp: true, // enables SMS message one-time password
passkey: true, // enables passkey sign-in
},
},
});
// You should also configure the user pool client with USER_AUTH authentication flow allowed
userPool.addClient('myclient', {
authFlows: { user: true },
});
python
user_pool = cognito.UserPool(self, "myuserpool",
sign_in_policy=cognito.SignInPolicy(
allowed_first_auth_factors=cognito.AllowedFirstAuthFactors(
password=True, # password authentication must be enabled
email_otp=True, # enables email message one-time password
sms_otp=True, # enables SMS message one-time password
passkey=True
)
)
)
# You should also configure the user pool client with USER_AUTH authentication flow allowed
user_pool.add_client("myclient",
auth_flows=cognito.AuthFlow(user=True)
)
java
UserPool userPool = UserPool.Builder.create(this, "myuserpool")
.signInPolicy(SignInPolicy.builder()
.allowedFirstAuthFactors(AllowedFirstAuthFactors.builder()
.password(true) // password authentication must be enabled
.emailOtp(true) // enables email message one-time password
.smsOtp(true) // enables SMS message one-time password
.passkey(true)
.build())
.build())
.build();
// You should also configure the user pool client with USER_AUTH authentication flow allowed
userPool.addClient("myclient", UserPoolClientOptions.builder()
.authFlows(AuthFlow.builder().user(true).build())
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
var userPool = new UserPool(this, "myuserpool", new UserPoolProps {
SignInPolicy = new SignInPolicy {
AllowedFirstAuthFactors = new AllowedFirstAuthFactors {
Password = true, // password authentication must be enabled
EmailOtp = true, // enables email message one-time password
SmsOtp = true, // enables SMS message one-time password
Passkey = true
}
}
});
// You should also configure the user pool client with USER_AUTH authentication flow allowed
userPool.AddClient("myclient", new UserPoolClientOptions {
AuthFlows = new AuthFlow { User = true }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
userPool := cognito.NewUserPool(this, jsii.String("myuserpool"), &UserPoolProps{
SignInPolicy: &SignInPolicy{
AllowedFirstAuthFactors: &AllowedFirstAuthFactors{
Password: jsii.Boolean(true),
// password authentication must be enabled
EmailOtp: jsii.Boolean(true),
// enables email message one-time password
SmsOtp: jsii.Boolean(true),
// enables SMS message one-time password
Passkey: jsii.Boolean(true),
},
},
})
// You should also configure the user pool client with USER_AUTH authentication flow allowed
userPool.addClient(jsii.String("myclient"), &UserPoolClientOptions{
AuthFlows: &AuthFlow{
User: jsii.Boolean(true),
},
})
Properties
adminUserPasswordoptionalbooleanadmin_user_passwordoptionalbooladminUserPasswordoptionalBooleanAdminUserPasswordoptionalboolAdminUserPasswordoptional*bool = false #Enable admin based user password authentication flow.
customoptionalbooleancustomoptionalboolcustomoptionalBooleanCustomoptionalboolCustomoptional*bool = false #Enable custom authentication flow.
Enable Choice-based authentication.
userPasswordoptionalbooleanuser_passwordoptionalbooluserPasswordoptionalBooleanUserPasswordoptionalboolUserPasswordoptional*bool = false #Enable auth using username & password.
userSrpoptionalbooleanuser_srpoptionalbooluserSrpoptionalBooleanUserSrpoptionalboolUserSrpoptional*bool = false #Enable SRP based authentication.