【问题标题】:Not allowed: no-auth-role/CognitoIdentityCredentials is not authorized to perform: geo:ListGeofences on resource: xxxxx不允许:no-auth-role/CognitoIdentityCredentials 无权执行:geo:ListGeofences on resource:xxxxx
【发布时间】:2021-09-11 17:45:52
【问题描述】:

我正在尝试使用 SDK 本身(位置)中的一些新的 Amazon 位置服务端点,但遇到了一些不一致的错误。

即使 IAM 角色 geo:* 中允许的所有内容(每个资源都相同),我总是发现 locationClient.listGeofences 之类的功能没有授权的错误。

随意,getMapStyleDescriptorsearchPlaceIndexForTextcalculateRoute 等其他一些函数不会出现问题。这些函数在geo:... 中使用它们各自的策略,所以看到它如何检测到一些策略而另一些没有,这让我很困惑。

该错误很常见,它显示以下内容以及它已被允许的政策:

Uncaught (in promise) AccessDeniedException: User: arn:aws:sts::xxxx:assumed-role/AmazonLocationTestRole/CognitoIdentityCredentials is not authorized to perform: geo:ListGeofences on resource: arn:aws:geo:eu-west-1:xxxx:*

请注意,该访问权限适用于在 Cognito 中具有身份池的未经身份验证的用户,但这应该不是问题。

                const client = new AWS.Location({
                    credentials: credentials,
                    region: AWS.config.region
                });

                console.log(await client.listGeofences({
                    CollectionName: "explore.geofence-collection"
                }).promise())

                console.log(await client.getMapStyleDescriptor({
                    MapName: mapName
                }).promise());

以防万一,IAM 角色中的信任关系如下所示:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Federated": "cognito-identity.amazonaws.com"
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringEquals": {
          "cognito-identity.amazonaws.com:aud": "eu-west-1:xxxx"
        },
        "ForAnyValue:StringLike": {
          "cognito-identity.amazonaws.com:amr": "unauthenticated"
        }
      }
    }
  ]
}

Amazon Location Service 中每个资源的每个策略都已被允许。

你知道会发生什么吗?

非常感谢!

【问题讨论】:

    标签: amazon-web-services aws-sdk amazon-cognito amazon-iam


    【解决方案1】:

    根据https://docs.aws.amazon.com/location/latest/developerguide/authenticating-using-cognito.html#cognito-create-user-pool,未经身份验证的身份只能访问以下操作:

    1. geo:GetMap*
    2. geo:SearchPlaceIndex*
    3. geo:BatchUpdateDevicePosition
    4. 地理:计算路线

    【讨论】:

      猜你喜欢
      • 2021-07-09
      • 2019-02-12
      • 2017-02-02
      • 1970-01-01
      • 1970-01-01
      • 2016-05-31
      • 2020-07-10
      • 2021-04-16
      • 2023-01-24
      相关资源
      最近更新 更多