我正在尝试使用 Jetty 上的 Jaas 设置基于 LDAP 的身份验证。
我首先配置了 Jetty->Jass
尝试使用属性文件登录模块,然后完成此操作后,我将更改为基于 Ldap 的登录模块...但我有一个奇怪的问题:
我有这个配置
jettyLogin {
org.eclipse.jetty.plus.jaas.spi.LdapLoginModule required
debug="true"
contextFactory="com.sun.jndi.ldap.LdapCtxFactory"
hostname="localhost"
port="1389"
bindDn="uid=admin,ou=People,o=acme,dc=example,dc=com"
bindPassword="admin"
authenticationMethod="simple"
forceBindingLogin="false"
userBaseDn="ou=People,o=acme,dc=example,dc=com"
userRdnAttribute="uid"
userIdAttribute="uid"
userPasswordAttribute="userPassword"
userObjectClass="inetOrgPerson"
roleBaseDn="ou=Roles,o=acme,dc=example,dc=com"
roleNameAttribute="cn"
roleMemberAttribute="member"
roleObjectClass="groupOfNames";
};
对于这样的 LDAP 条目
dn: uid=jduke,ou=People,o=acme,dc=example,dc=com
objectclass: top
objectclass: inetOrgPerson
objectclass: person
uid: jduke
cn: Java
sn: Duke
userPassword: theduke
mail: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4f252b3a242a0f2e2c222a612a372e223f232a612c2022" rel="noreferrer noopener nofollow">[email protected]</a>
我看到的是 LdapLoginModule
被调用并搜索用户;找到用户,但在检索属性时,缺少 userPassword 属性 (!!) ...然后它保持为空并且身份验证失败。
我无法理解为什么未检索到 userPassword
属性。
最佳答案
登录模块不应尝试检索 userPassword 属性。 LDAP 是一种身份验证协议(protocol),有自己的方法(称为绑定(bind))。
如果您配置正确,Jetty 的 JAAS 模块将尝试使用提供的凭据执行绑定(bind)。如果你改变
forceBindingLogin="false"
至
forceBindingLogin="true"
在您的配置中,那么它应该适合您。
关于java - 使用 Jetty 进行 LDAP 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21160295/