即使禁用安全性,OAuth令牌API也无法在弹性搜索中工作 [英] OAuth Token API Not Working In Elastic Search Even Security Disabled

查看:143
本文介绍了即使禁用安全性,OAuth令牌API也无法在弹性搜索中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是弹性搜索的新手,使用的是弹性搜索版本7.7.1

I'm new to Elastic search, using Elastic search version 7.7.1

我想通过遵循当我在下面尝试过时,请通过Kibana致电以根据文档获取OAuth令牌:

When I've Tried below call through Kibana to get the OAuth token as per documentation:

 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
}

任何人都可以帮助解决此问题吗?

推荐答案

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

Elasticsearch creates the special index called .security-7 in version 7.X when x-pack security is enabled by setting xpack.security.enabled: true and to access this index, you need to give _security as index name when calling the security API like creating role, users etc

下面是一个这样的示例,其中在启用x-pack安全性的情况下创建了test角色.

Below is one such example where I created the test role when x-pack security is enabled.

端点http://{{hostname}}:{{port}}/_security/role/test//注意_security

endpoint http://{{hostname}}:{{port}}/_security/role/test // notice _security

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

注意:在您的情况下,除非启用了x-pack-security,否则它将不起作用,并且您无法创建_security索引作为其特殊索引,该特殊索引可以以_开头并由x-仅包装.

Note: In your case, it would not work unless x-pack-security is enabled and you can't create _security index as its a special index which can be started with _ and is created by x-pack only.

这篇关于即使禁用安全性,OAuth令牌API也无法在弹性搜索中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆