问题描述
我是弹性搜索的新手,使用的是弹性搜索版本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也无法在弹性搜索中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!