ES创建只读用户

1.创建对指定索引集合的只读角色(names:* 指所有)


POST /_security/role/read_only
{
  "indices": [
    {
      "names": [
        "test-index",
      ],
      "privileges": [
        "read"
      ]
    }
  ]
}

2.创建用户并指定为只读角色


POST /_security/user/test_user
{
  "password" : "123456",
  "roles" : ["read_only"]
}

命令行创建

###1)新建testuser角色
curl -H 'Content-Type:application/json' -XPUT -u elastic:123456 "http://192.168.10.103:9200/_security/role/read_only" -d '{
"cluster":["monitor"],
"indices":[{"names":["*"],"privileges":["read","monitor"]}]
}'
###返回create:true表示创建成功.
###2)新建testuser用户
curl -H 'Content-Type:application/json' -XPUT -u elastic:123456 "http://192.168.10.103:9200/_security/user/testuser" -d '{
"password":"test123456","roles":["read_only"]
}'
###返回create:true表示创建成功,结束流程。
###参考至 https://cloud.tencent.com/developer/ask/sof/1514433

posted @ 2023-03-09 14:21  whiteY  阅读(1255)  评论(0)    收藏  举报