Xpack集成LDAP
支持两种配置方式:
The ldap realm supports two modes of operation, a user search mode and a mode with specific templates for user DNs.
a、User Search Mode
b、User DN Templates Mode
这里我用的是第二种,因为不需要明文配置LDAP的admin密码。
1、修改ES配置文件,添加LDAP配置
# vim /etc/elasticsearch/elasticsearch.yml
xpack:
security:
authc:
realms:
ldap1:
type: ldap
order: 0
url: "ldap://192.168.2.164:389"
user_dn_templates:
- "uid={0},ou=Users,dc=beijing,dc=op"
group_search:
base_dn: "dc=beijing,dc=op"
files:
role_mapping: "/etc/elasticsearch/x-pack/role_mapping.yml"
unmapped_groups_as_roles: false
url 中,ldap协议表示使用普通连接,端口为389。ldaps 表示使用 ssl 安全连接,端口为636.
为了避免单点故障,这里支持负载均衡和故障转移,实现多个LDAP节点高可用。
Load Balancing and Failover
The load_balance.type
setting can be used at the realm level to configure how X-Pack security should interact with multiple LDAP servers.
X-Pack security supports both failover and load balancing modes of operation.
配置格式:
2、修改role_mapping文件,给用户指定权限
# vim /etc/elasticsearch/x-pack/role_mapping.yml
superuser:
- "uid=shengyongp,ou=Users,dc=beijing,dc=op"
默认 xpack 每五秒会检查一次 role_mapping 文件的变化,也就是修改用户权限之后不用重载ES。
By default, X-Pack security checks role mapping files for changes every 5 seconds.
其他细节请参考官网文档。