【问题标题】:Can AWS Amplify Analytics be used without a Cognito User Pool?是否可以在没有 Cognito 用户池的情况下使用 AWS Amplify Analytics?
【发布时间】:2020-08-14 15:16:53
【问题描述】:

我正在尝试通过 Amplify SDK 将 Pinpoint Analytics 实施到现有的 React Native 应用程序中。我们有一个现有的用户群和我们自己的 authN 和 authZ 实现,所以我们不需要(更重要的是,买不起)Cognito 用户池。

一方面,Pinpoint API 在recording events 时不需要与 Cognito 进行任何集成,但在使用 analytics 时,amplify documentation 似乎需要 auth 插件,而在配置时需要 auth 参数放大。

Amplify.configure({
    // To get the AWS Credentials, you need to configure 
    // the Auth module with your Cognito Federated Identity Pool
    Auth: {
        identityPoolId: 'us-east-1:xxx-xxx-xxx-xxx-xxx',
        region: 'us-east-1'
    },
    Analytics: {
        // OPTIONAL - disable Analytics if true
        disabled: false,
       ...

有没有办法通过 Amplify 使用analytics 而不生成用户池?我试过检查 AWS 移动 SDK,但它们显然已被弃用,现在大多数文档都指向 Amplify。我们可以直接使用 Pinpoint API,但这种实现似乎有点多余。

【问题讨论】:

    标签: aws-amplify aws-pinpoint aws-amplify-cli


    【解决方案1】:

    免责声明:我不是 AWS Amplify/Cognito/Pinpoint 产品团队的成员。

    根据我的研究,AWS Amplify Analytics(Amazon Pinpoint) 可以在没有 Cognito 用户池的情况下使用,但需要 Cognito 身份池进行授权。

    Cognito 用户池和 Cognito 身份池的概念有时可能令人困惑,但简单来说,我将它们区分如下:

    Amazon Cognito 用户池是一项功能齐全的用户目录服务,用于处理用户注册、存储、身份验证和帐户恢复。

    Amazon Cognito 身份池(联合身份)是一种授权在您的应用中使用 AWS 服务的方法。

    当您将应用程序与 Amazon Pinpoint 集成时,应用程序需要访问 AWS 服务的权限。因此,Amazon Cognito 身份池提供了一种授权在您的应用程序中使用 AWS 服务的方法。使用 Cognito 身份池,您可以获得临时具有您通过 IAM 策略定义的访问 AWS 服务的权限的 AWS 凭证。IAM 策略(auth_role 和 unauth_role)应包含允许您将数据发送到服务的 Pinpoint 相关策略。请参阅下面的示例:

    {
        "Version": "2012-10-17",
        "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "mobiletargeting:UpdateEndpoint",
                "mobiletargeting:PutEvents"
            ],
            "Resource": [
                "arn:aws:mobiletargeting:*:${accountID}:apps/${appId}*"
            ]
        }
        ]
    }
    

    总结:

    使用 Amazon Cognito 身份池提供了一种更安全可靠的方式来访问您的应用程序中的 AWS 后端资源,而不是将凭证(即访问密钥和秘密密钥)嵌入到您的应用程序中。

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 2019-06-24
      • 2021-06-16
      • 2020-09-14
      • 2023-03-20
      • 2019-09-13
      • 2018-04-12
      • 2020-06-22
      • 2021-04-26
      • 2020-12-31
      相关资源
      最近更新 更多