【问题标题】:Set Cognito Verification Type to Link in CloudFormation在 CloudFormation 中将 Cognito 验证类型设置为链接
【发布时间】:2018-07-10 07:25:30
【问题描述】:

我试图弄清楚如何在我的 CloudFormation 模板中将验证类型从 Code(默认)设置为 Link

在网站我可以在这里设置:

如果我看一下docs,就没有提到任何内容。 我的 CloudFormation 看起来像

SomeUserPoolResourceName:
  Type: AWS::Cognito::UserPool
  Properties:
    UserPoolName: SomeResource_User_Pool
    EmailVerificationType: Link  # I want something like this
    EmailVerificationSubject: 'Your verification link'
    EmailVerificationMessage: 'Please click the link below to verify your email address. {##Verify Email##}' # fails because {####} is required
    AliasAttributes:
      - email
    AutoVerifiedAttributes:
      - email
    Policies:
      PasswordPolicy:
        - .... 
    Schema:
      - ....

是否可以通过 CloudFormation 进行配置?

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation amazon-cognito


    【解决方案1】:

    谢谢Daniel Golgher

    这个变通方法被证明是一个很好的解决方案。

    我的代码看起来像:

    UserPool:
        Type: "AWS::Cognito::UserPool"
        Properties:
          UserPoolName:
            Fn::If:
              - IsDevelopment
              - !Sub "${ApplicationName}-${Environment}-${User}-${Module}-user-pool"
              - !Sub "${ApplicationName}-${Environment}-${Module}-user-pool"
          UsernameAttributes: [email]
          AutoVerifiedAttributes:
            - email
          VerificationMessageTemplate:
            DefaultEmailOption: CONFIRM_WITH_LINK
          EmailVerificationSubject: verify your email id for ${ApplicationName}
          EmailVerificationMessage: Please click the link below to verify your email address. {####}
    

    【讨论】:

      【解决方案2】:

      试试这个:

      SomeUserPoolResourceName:
        Type: AWS::Cognito::UserPool
        Properties:
          UserPoolName: SomeResource_User_Pool
          VerificationMessageTemplate:
             DefaultEmailOption: CONFIRM_WITH_LINK
          EmailVerificationSubject: 'Your verification link'
          EmailVerificationMessage: 'Please click the link below to verify your email address. {##Verify Email##}' # fails because {####} is required
          AliasAttributes:
            - email
          AutoVerifiedAttributes:
            - email
          Policies:
            PasswordPolicy:
              - .... 
          Schema:
      

      改变这部分:

      EmailVerificationType: Link  # I want something like this
      

      为:

      VerificationMessageTemplate:
        DefaultEmailOption: CONFIRM_WITH_LINK
      

      【讨论】:

      • Properties: VerificationMessageTemplate: DefaultEmailOption: CONFIRM_WITH_LINK 对我有用——即使在无服务器框架中也是如此。
      • @DanielGolgher 这真的有效吗?无论哪种方式,使用 EmailSubjectByLink 和 EmailMessageByLink 属性可能更一致,这些属性应该作为 DefaultEmailOption 属性的兄弟姐妹,根据您的文档链接。
      【解决方案3】:

      如果您有自定义消息 lambda 触发器,则可以轻松地将链接放入其中。

      <a href="https://[your domain]/confirmUser?client_id=[your clientId]&user_name=" + event.request.userAttributes.sub + "&confirmation_code=" + event.request.codeParameter + ">Click here to verify your account</a>
      

      【讨论】:

      • 我喜欢这个想法,因为我可以用它来解决不同的问题。感谢分享。
      【解决方案4】:

      不,目前不可能。根据更新的CreateUserPool API,新的 VerificationMessageTemplate 参数将允许我们执行此操作,但 cloudformation 尚未支持此操作。 AWS Support 告诉我们有一个现有的功能请求。您可以查看自定义 cloudformation 资源作为解决方法。

      【讨论】:

      • 感谢您的回答。完全符合我的预期。
      • 你有看到这方面的任何更新吗?我在任何地方都找不到任何文档
      • 对于任何寻求帮助的人,相同的参数现在已添加到 CF 但是我正在努力解决 VerificationMessageTemplate.EmailMessageByLinkEmailVerificationSubject 之间的区别两者之间有什么不同?
      猜你喜欢
      • 2021-05-31
      • 2022-12-14
      • 1970-01-01
      • 2021-05-31
      • 2012-07-10
      • 2018-04-08
      • 2018-05-17
      • 2015-01-30
      • 2019-10-26
      相关资源
      最近更新 更多