Search Guard 1.3 测试配置

发布时间:2024-11-13 21:11

测试配置

在上面三个小节Search Guard 1.0、 1.1、1.2中,我们配置了用户和角色。现在来测试一下这些配置是否成功。

本文:

检查配置的用户

访问Elasticsearch

在检查之前,我们看下需要的配置:

在sg_internal_users.yml中创建用户

在sg_roles.yml中创建角色

在sg_roles_mapping.yml创建一个映射去连接用户和Search Guard的角色对应

检查配置的用户

作为第一步,我们想去检查我们配置的的用户是否在且映射到正确的Search Guard角色。

Search Guard 提供了一个HTTP去检查一个用户的属性。

https://<node name>:<http port>/_searchguard/authinfo?pretty 1

为了获取用户信息,我们需要提供用户名和密码。通过这个连接这个端点检查jode用户的属性:

curl -k -u jdoe:jdoe -XGET "https://sgssl-0.example.com:9200/_searchguard/authinfo?pretty" 1

这个返回内容:

{ "user" : "User [name=jdoe, backend_roles=[hr_department], requestedTenant=null]", "user_name" : "jdoe", ... "backend_roles" : [ ​ "hr_department" ], "sg_roles" : [ ​ "sg_human_resources" ], ... } 123456789101112

在返回的JSON中,可以看到创建的用户和被分配到正确的Search Guard角色:

"user_name":"jdoe"

这是在sg_internal_users.yml配置的用户。

"backend_roles":[“hr_department”]

这是在sg_internal_users.yml中用户jdoe分配的后端角色。

"sg_roles":[“sg_human_resources”]

这个是为了用户jdoe分配Search Guard的角色。这意外这映射对于此用户Search Guard被期望的那样工作。

访问Elasticsearch

现在,我们要确信我们的用户jdoe是正确映射到Search Guard角色sg_human_resources。在Elasticsearch中可以试着访问一些数据。
这个定义的角色比如:

sg_human_resources: cluster_permissions: ​ - "SGS_CLUSTER_COMPOSITE_OPS" index_permissions: ​ - index_patterns: ​ - "humanresources" ​ allowed_actions: ​ - "SGS_READ" 12345678

我们期望用户jdoe可以读取索引humanresources的数据,但不能访问其他任何数据。

首先,我们试着访问索引humanresources的数据。

curl -k -u jdoe:jdoe -XGET "https://IP:9200/humanresources/_search?pretty" 1

正如预期一样,访问是被允许的,且从这个索引返回了数据。

{ "took" : 216, "timed_out" : false, "_shards" : { ... }, "hits" : { ​ "total" : { ​ ... ​ }, ​ "max_score" : 1.0, ​ "hits" : [ ​ { ​ "_index" : "humanresources", ​ "_type" : "_doc", ​ "_id" : "3", ​ "_score" : 1.0, ​ "_source" : { ​ "FirstName" : "CHASE", ​ "LastName" : "CRUDO", ​ "Designation" : "President", ​ } ​ }, ​ ...

123456789101112131415161718192021222324

如果我们试着访问索引devops的数据,正如预期一样访问是被拒绝的。

curl -k -u jdoe:jdoe -XGET "https://sgssl-0.example.com:9200/devops/_search?pretty" 1

{ "error" : { ​ "root_cause" : [ ​ { ​ "type" : "security_exception", ​ "reason" : "no permissions for [indices:data/read/search] and User [name=jdoe, roles=[hr_department], requestedTenant=null]" ​ } ​ ], ​ "type" : "security_exception", ​ "reason" : "no permissions for [indices:data/read/search] and User [name=jdoe, roles=[hr_department], requestedTenant=null]" }, "status" : 403 } 123456789101112131415

额外的资源

Troubleshooting user problems

Troubleshooting permission problems

下面是单词:

troubleshooting:*英 /ˈtrʌblʃuːtɪŋ/ *

v 检修;当调解人

n 解决纷争,发现并修理故障

网址:Search Guard 1.3 测试配置 https://www.yuejiaxmz.com/news/view/68878

相关内容

血糖测试仪
静电测试基本原理.ppt
食品储存期加速测试及其应用.pdf
ORCL 数据库的安装配置
LFS经验总结
家居清洁用品测试
PyCharm+Python3.8+OpenCV4.1集成环境安装配置
hr面试性格测试30题
软件测试工程师的日常生活
社交心理测试题

随便看看