注意:该项功能需要license
Ldap测试命令
ldapsearch -x -D "cn=username, ou=people, dc=example, dc=com" -w password -b "dc=example,dc=com" -p 389 -h ldap.example.com
elasticsearch.yml 修改
order 数值越小越优先, ES7.X版本文档的配置项稍有不同,下面这个是6.X的配置,应该是兼容的
xpack:
security:
authc:
realms:
ldap1:
type: ldap
order: 0
url: "ldap://ldap.example.com:389"
bind_dn: "cn=username, ou=people, dc=example, dc=com"
bind_password: password
user_search:
base_dn: "dc=example,dc=com"
filter: "uid={0}"
unmapped_groups_as_roles: false
native1:
type: native
order: 1
必须每个节点都这么设置,然后重启节点
角色与权限配置
访问 kibana -> management -> roles
点击 create role 创建角色
按说明配置角色相关权限
配置完成后点击 save 保存。
用户角色绑定
LDAP 用户目前不支持通过 UI 界面配置,需要使用 API 来管理
详情请参考:
https://www.elastic.co/guide/en/elasticsearch/reference/6 api-put-role-mapping.html
访问 kibana -> dev tools 界面,使用下一 API 创建用户角色关联:
POST security/role_mapping/<role_mapping_name>
{
"roles": [
"test" //这里填写需要绑定的角色名,例如上面我们创建的test角色q
],
"enabled": true,
"rules": {
"any": [
{
"field": {
"username": [
"esadmin" //这里填写需要绑定的ldap用户名
]
}
},
{
"field": {
"groups": "cn=admins,dc=example,dc=com" //也可以把角色绑定到ldap用户组上
}
}
]
}
}