【问题标题】:OAuth Token API Not Working In Elastic Search Even Security DisabledOAuth 令牌 API 无法在弹性搜索中工作,甚至禁用安全性
【发布时间】:2023-04-04 05:42:01
【问题描述】:

我是 Elastic 搜索的新手,使用的是 Elastic 搜索 7.7.1 版

我想通过关注Elastic Search documentation来生成OAuth令牌

当我尝试通过 Kibana 调用下面的方法以根据文档获取 OAuth 令牌时:

 POST /_security/oauth2/token
    {
      "grant_type" : "password",
      "username" : "elastic",
      "password" : "password_for_elastic_super_user"
    }

然后低于错误:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "invalid_index_name_exception",
        "reason" : "Invalid index name [_security], must not start with '_', '-', or '+'",
        "index_uuid" : "_na_",
        "index" : "_security"
      }
    ],
    "type" : "invalid_index_name_exception",
    "reason" : "Invalid index name [_security], must not start with '_', '-', or '+'",
    "index_uuid" : "_na_",
    "index" : "_security"
  },
  "status" : 400
}

谁能帮忙解决这个问题?

【问题讨论】:

  • 您需要在弹性搜索节点中启用安全性。你的elasticsearch.yml 配置是什么样的?用它更新你的问题。
  • 如果我启用了安全性然后会出现另一个问题,请检查:stackoverflow.com/questions/62575068/…

标签: java spring-boot elasticsearch oauth-2.0 kibana


【解决方案1】:

当通过设置xpack.security.enabled: true 启用x-pack 安全性时,Elasticsearch 在版本7.X 中创建名为.security-7 的特殊索引,并且要访问此索引,您需要在调用安全API 时将_security 作为索引名称比如创建角色、用户等

下面是一个这样的示例,我在启用 x-pack 安全性时创建了test 角色。

端点 http://{{hostname}}:{{port}}/_security/role/test // 通知_security

{
    "indices": [
        {
            "names": [
                "ngram*"
            ],
            "privileges": [
                "all"
            ]
        }
    ]
}

注意:在您的情况下,除非启用 x-pack-security 并且您不能创建 _security 索引作为它可以以 _ 开头并由 x- 创建的特殊索引,否则它将不起作用只打包。

【讨论】:

    猜你喜欢
    • 2020-10-15
    • 2011-10-29
    • 1970-01-01
    • 2016-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多