【问题标题】:{"Message":"User: anonymous is not authorized to perform: es:ESHttpGet"} error when accessing AWS elasticsearch endpoint{"Message":"User:anonymous is not authorized to perform:es:ESHttpGet"} 访问 AWS elasticsearch 端点时出错
【发布时间】:2022-01-28 06:59:18
【问题描述】:

我有一个 AWS elasticsearch 服务,并且还配置了 cognito 身份验证,现在我无法访问我的 elasticsearch 端点,我收到“{“Message”:“用户:anonymous is not authorized to执行:es:ESHttpGet"}" 错误。以下是我的 JSON 访问策略 -

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::<<Account_Number>>:role/Cognito_kibana_identitiesAuth_Role"
      },
      "Action": "es:ESHttp*",
      "Resource": "arn:aws:es:us-east-2:<<Account_Number>>:domain/<<Domain_Name>>/*"
    }
  ]
}

我知道这可能是一个重复的问题,但鉴于我也启用了 cognito 访问,我无法找到如何更改我的访问策略。我对 ELK 很陌生。有什么我遗漏的吗?

【问题讨论】:

    标签: elasticsearch amazon-cognito


    【解决方案1】:

    如果经过身份验证的用户收到此错误,则错误消息将包含User: x:x:x:x is not authorized...,但您收到的错误消息为User: anonymous is not authorized...。这表明用户未通过身份验证,问题在于 Cognito 身份验证或角色假设。

    1. 您是否直接使用未经身份验证的用户来承担 Cognito id 池身份验证角色?
    2. 请检查使用 Cognito 身份池配置的身份验证角色的信任策略。它需要遵循:https://docs.aws.amazon.com/cognito/latest/developerguide/role-trust-and-permissions.html

    对于认证用户,"cognito-identity.amazonaws.com:amr": "authenticated"需要在条件下使用。

    【讨论】:

    • 我可以使用我设置的用户名和密码登录到 kibana,但无法使用命令提示符访问 elasticsearch 端点或 API,你能指导我我需要做什么才能做到这一点吗?仅供参考 - 我目前使用 kibana 开发。控制台执行 API 调用,但我需要从命令提示符中获取它
    • @VidhyaDhara AFAIK,无法使用命令提示符(使用 AWS CLI)或任何 AWS 开发工具包。因为,Kibana 和 Cognito 之间的身份验证流程发生在 OAuth 2.0 协议中。这是一个基于浏览器的协议。该协议使用存储在浏览器中的 cookie,在 CLI 或 SDK 中无法像浏览器那样存储 cookie。
    猜你喜欢
    • 2020-10-25
    • 1970-01-01
    • 1970-01-01
    • 2016-10-03
    • 1970-01-01
    • 2014-11-09
    • 2021-05-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多