ElasticSearch7.10配置Search-Guard之配置用户

ElasticSearch7.10配置Search-Guard之配置用户

配置sg_internal_user.yml

密码是:elastic

jode:

  hash: $2y$12$nUzkcjdnufzvI1HlmN7xSuND3skGhmwV5le5IINejz.asMFpLYNRy

  backend_roles:

  - "hr_department"



psmith:

  hash: $2y$12$nUzkcjdnufzvI1HlmN7xSuND3skGhmwV5le5IINejz.asMFpLYNRy

  backend_roles:

  - "hr_department"



cmaddock:

  hash: $2y$12$nUzkcjdnufzvI1HlmN7xSuND3skGhmwV5le5IINejz.asMFpLYNRy

  backend_roles:

  - "devops"

sg_roles.yml

sg_human_resources:

  cluster_permissions:

​     - "SGS_CLUSTER_COMPOSITE_OPS"

  index_permissions:

​     - index_patterns:

​       - "humanresources"

​       allowed_actions:

​         - "SGS_READ"





sg_devops:

  cluster_permissions:

​     - "SGS_CLUSTER_COMPOSITE_OPS"

  index_permissions:

​     - index_patterns:

​       - "infrastructure"

​       allowed_actions:

​         - "SGS_READ"

​         - "SGS_WRITE"

​     - index_patterns:

​        - "logs-*"

​        allowed_actions:

​          - "SGS_READ"

sg_roles_mapping.yml

sg_human_resources:

  backend_roles:

​     - "hr_department"



sg_devops:

  backend_roles:

​     - "devops"

sgadmin命令

./sgadmin.sh -cd ../sgconfig/ 

-cert /home/software/es_ssl/es/config/certs/kirk.crtfull.pem

-key /home/software/es_ssl/es/config/certs/kirk.key.pem 

-cacert /home/software/es_ssl/es/config/certs/root-ca.pem 

-keypass changeit 

-nhnv 

-icl

创建索引

(1)用jode

  • 去创建索引、删除索引

  • 去查询除了humanresources索引之外的索引

(2)用cmaddock

  • 去创建索引、删除索引

  • 去查询infrastructure索引、写入数据

  • 去查询log开头的索引、写入

  • 查询、写入其他索引

jode操作

创建索引

返回来的异常信息,为admin才能创建索引,失败了。

创建文档
{

​    "username":"张三",

​    "age":18,

​    "gender":"male"

}

以经用admin创建了humanresources索引,现在用jode用户去写入数据,明显无权限,由于jode属于hr_department角色,只能有查询humanresources的权限

查询索引

查询humanresources索引,能查询出数据。

我现在用jode用户,查询infrastructure索引,显示无权限。

cmaddock操作

cmaddockdevops角色的用户,有两个索引,其中infrasturcture可以读和写的权限,*logs-**只可以读

创建索引

显然是无权限,正确。

创建文档

显示成功,正确

对于logs-*索引,无写权限,如下:

查询索引

infrastructure索引

显示数据,成功。

logs-*索引

我创建了logs-2023log-2023两个索引。

查询log-2023

显示无权限,正确,由于对于logs-*正则表达式的索引,才能查询。

查询logs-2023

显示数据,成功

posted @ 2023-01-17 12:18  山沉  阅读(55)  评论(0编辑  收藏  举报