<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-auth-ldap</artifactId>
<version>5.0.12</version>
</dependency>
认证与权限安全
你当前正在浏览历史版本 Vert.x 4.3.8 的文档。 访问本页面的 最新版本。
LDAP 身份认证提供者 (vertx-auth-ldap)
该组件是基于 LDAP(轻量级目录访问协议)协议进行用户身份认证的提供者实现。
快速上手
在项目构建描述文件中添加以下依赖:
-
Maven(在
pom.xml中):
-
Gradle(在
build.gradle文件中):
compile 'io.vertx:vertx-auth-ldap:5.0.12'
实例化
通过调用 LdapAuthentication.create 创建 LDAP 认证提供者实例:
参数配置
类 LdapAuthenticationOptions 用于配置 LDAP 认证提供者:
authenticationQuery-
查找特定 ID 用户时使用的 LDAP 查询语句。例如
uid={0},ou=users,dc=foo,dc=com,占位符{0}将在执行查询时被实际的用户 ID 替换。此项配置为必填项。 url-
LDAP 服务器连接地址。URL 必须以
ldap://开头且必须显式指定端口号,例如ldap://myldapserver.mycompany.com:10389。 authenticationMechanism-
设置连接 LDAP 服务器时采用的认证机制类型。
referral-
设置建立连接时的 LDAP 引用跟踪(Referral)策略,默认值为
follow。更多详细信息请参阅 Sun/Oracle LDAP 引用官方指南:http://java.sun.com/products/jndi/tutorial/ldap/referral/jndi.html
注意事项
使用该实现执行身份验证时,传入的认证凭据(Authentication Info)中必须包含 username 与 password 字段。