amazon-web-services - AWS Cognito:无法使用 aws cli 为 create-user-pool 设置一些属性
问题描述
我正在尝试使用来自 json 文件的 AWS CLI 在 cognito 上创建一个用户池。正在创建池,但我无法设置它的某些属性。
注意:下面附加的一些快照取自用于创建用户池的 AWS Docs。
我无法找到将电子邮件设置为验证属性的方法。
快照:
尽管我在 json 文件中指定了电子邮件消息和主题,但并未自定义它们。这让我想到了另一个问题(第 3 点)。
通过 CLI 创建用户池的 AWS 文档提到了三个属性。
- --email-verification-message(一个字符串)。
- --email-verification-subject(一个字符串)。
- --verification-message-template (一个结构) - 这具有设置消息和主题模板的属性。如果使用此结构(验证消息模板),前两个属性(电子邮件验证消息和主题)是否必要?由于该结构包含在内部设置消息和主题(请参阅下面的快照)。我都使用过,但仍然无法设置消息并选择验证链接作为选项而不是验证码。
快照:
下面是我为创建池而形成的 JSON 对象
{
"PoolName": "xxx-userpool-local",
"Policies": {
"PasswordPolicy": {
"MinimumLength": 8,
"RequireUppercase": true,
"RequireLowercase": true,
"RequireNumbers": true,
"RequireSymbols": true,
"TemporaryPasswordValidityDays": 7
}
},
"UsernameAttributes": [
"email"
],
"EmailVerificationMessage": "Please click the link below to verify your account. {####}",
"EmailVerificationSubject": "Your account is ready",
"VerificationMessageTemplate": {
"EmailMessage": "Please click the link below to verify your account. {####}",
"EmailSubject": "Your account is ready",
"EmailMessageByLink": "Please click the link below to verify your account. {####}",
"EmailSubjectByLink": "Your account is ready",
"DefaultEmailOption": "CONFIRM_WITH_LINK"
},
"AdminCreateUserConfig": {
"AllowAdminCreateUserOnly": false
},
"UsernameConfiguration": {
"CaseSensitive": true
},
"AccountRecoverySetting": {
"RecoveryMechanisms": [
{
"Priority": 1,
"Name": "verified_email"
}
]
}
}
解决方案
- 控制台中的此选项映射到
AutoVerifiedAttributes
CLI 中。要将电子邮件设置为验证属性,请将以下代码片段添加到您的 JSON 输入中:
"AutoVerifiedAttributes": [
"email"
]
- 它映射到
AdminCreateUserConfig.InviteMessageTemplate
CLI 中。
"AdminCreateUserConfig": {
"AllowAdminCreateUserOnly": false,
"InviteMessageTemplate": {
"EmailMessage": "Your username is {username} and temporary password is {####}. ",
"EmailSubject": "Your temporary password"
}
}
- 您可以使用以下配置来选择验证链接作为选项而不是验证码。
"VerificationMessageTemplate": {
"EmailMessageByLink": "Please click the link below to verify your email address. {##Verify Email##} ",
"EmailSubjectByLink": "Your verification link",
"DefaultEmailOption": "CONFIRM_WITH_LINK"
}
推荐阅读
- python - Selenium(PYTHON) 获取 href 的特定属性
- user-agent - Core Web Vitals 的用户代理是什么?
- swift - Swift - 如何在不同函数中更新变量,当所有函数在页面加载时运行,然后才能声明变量
- python - KivyMD 带有下拉菜单的文本字段
- c++ - 是否有一个 C++ API Linux 系统调用可以告诉您可执行文件链接了哪些共享库?
- typescript - 模板文字作为 Typescript 中的函数参数
- c# - 首选项 Xamarin.Essentials - 第一次检查是否为空?
- asp.net-core - IConfigureOptions 的生命周期
和 IHostingEnvironment 实现服务类 - sql - Angular fullcalendar 显示来自 Angular 服务的事件
- c# - C# 中的自定义字符串占位符