【问题标题】:AWS Cognito: Unable to set some properties for create-user-pool using aws cliAWS Cognito:无法使用 aws cli 为 create-user-pool 设置一些属性
【发布时间】:2021-10-07 11:26:17
【问题描述】:

我正在尝试使用来自 json 文件的 AWS CLI 在 cognito 上创建用户池。正在创建池,但我无法设置它的某些属性。

注意:下面附加的一些快照取自AWS Docs for creating user pool

  1. 我无法找到将电子邮件设置为验证属性的方法。

    快照:

  2. 尽管我在我的 json 文件中指定了电子邮件消息和主题,但没有自定义它们。这让我想到了另一个问题(第 3 点)。

  3. 通过 CLI 创建用户池的 AWS 文档提到了三个属性。

  • --email-verification-message(一个字符串)。
  • --email-verification-subject(字符串)。
  • --verification-message-template(A 结构)- 它具有设置消息和主题模板的属性。如果使用此结构(验证消息模板),前两个属性(电子邮件验证消息和主题)是否必要?由于该结构包含在内部设置消息和主题(请参阅下面的快照)。两者我都用过,但仍然无法设置消息并选择验证链接作为选项而不是验证码。

快照:

下面是我为创建池而形成的 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"
            }
        ]
    }
}

【问题讨论】:

    标签: amazon-web-services amazon-cognito aws-cli


    【解决方案1】:
    1. 控制台中的此选项映射到 CLI 中的 AutoVerifiedAttributes。要将电子邮件设置为验证属性,请将以下代码 sn-p 添加到您的 JSON 输入中:
    "AutoVerifiedAttributes": [
     "email"
    ]
    
    1. 它映射到 CLI 中的 AdminCreateUserConfig.InviteMessageTemplate
    "AdminCreateUserConfig": {
      "AllowAdminCreateUserOnly": false,
      "InviteMessageTemplate": {
        "EmailMessage": "Your username is {username} and temporary password is {####}. ",
        "EmailSubject": "Your temporary password"
      }
    }
    
    1. 您可以使用以下配置选择验证链接作为选项,而不是验证码。
    "VerificationMessageTemplate": {
      "EmailMessageByLink": "Please click the link below to verify your email address. {##Verify Email##} ",
      "EmailSubjectByLink": "Your verification link",
      "DefaultEmailOption": "CONFIRM_WITH_LINK"
    }
    

    【讨论】:

      猜你喜欢
      • 2020-06-06
      • 1970-01-01
      • 2019-10-30
      • 1970-01-01
      • 1970-01-01
      • 2020-08-09
      • 1970-01-01
      • 2021-05-31
      • 2022-11-10
      相关资源
      最近更新 更多