ldap_auth
> 文档中心 > 文档中心 > INFINI Gateway > 功能手册 > 在线过滤器 > ldap_auth

ldap_auth #

描述 #

ldap_auth 过滤器用来设置基于 LDAP 的身份认证。

配置示例 #

一个简单的示例如下:

flow:
  - name: ldap_auth
    filter:
      - ldap_auth:
          host: "ldap.forumsys.com"
          port: 389
          bind_dn: "cn=read-only-admin,dc=example,dc=com"
          bind_password: "password"
          base_dn: "dc=example,dc=com"
          user_filter: "(uid=%s)"

上面的配置使用的是在线的免费 LDAP 测试服务器,测试用户 tesla,密码 password

➜  curl  http://127.0.0.1:8000/ -u tesla:password
{
  "name" : "192.168.3.7",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "ZGTwWtBfSLWRpsS1VKQDiQ",
  "version" : {
    "number" : "7.8.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "757314695644ea9a1dc2fecd26d1a43856725e65",
    "build_date" : "2020-06-14T19:35:50.234439Z",
    "build_snapshot" : false,
    "lucene_version" : "8.5.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
➜  curl  http://127.0.0.1:8000/ -u tesla:password1
Unauthorized%

参数说明 #

名称类型说明
hoststringLDAP 服务器地址
portintLDAP 服务器端口,默认 389
tlsboolLDAP 服务器是否为 TLS 安全传输协议,默认 false
bind_dnstring执行 LDAP 查询的用户信息
bind_passwordstring执行 LDAP 查询的密码信息
base_dnstring过滤 LDAP 用户的根域
user_filterstring过滤 LDAP 用户的查询条件,默认 (uid=%s)
uid_attributestring用于用户 ID 的属性,默认 uid
group_attributestring用于用户组的属性,默认 cn
attributearray指定 LDAP 查询返回的属性列表
max_cache_itemsint最大的缓存格式,默认不限制
cache_ttlduration缓存过期时间格式,默认 300s