2014-01-16 195 views
1

我正尝试在Jetty上与Jaas建立基于LDAP的身份验证。使用Jetty进行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"; 
    }; 

像这样

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: [email protected] 

我看到一个LDAP条目是LdapLoginModule被调用,并为使用searchs R等用户被发现,但是当属性被检索时userPassword属性丢失(!!)...然后它保持为空并且认证失败。

我不明白为什么userPassword属性没有检索。

+1

几乎没有LDAP实现将返回一个userPassword值,他们不应该。您不应该期望获得userpassword的值。用户应该提供密码,应用程序应该以用户身份绑定。 – jwilleke

+0

mmm ......也许我错了,但正如我所看到的那样,验证用户的操作不是由LDAP服务器完成的......所以服务器应该以任何方式提供密码,以便将其与由用户...这,认证的动作是由登录模块执行的。通过这种方式,Ldap登录模块的代码看起来非常清晰。它期望找到由LDAP检索到的userPassword属性。 – Rafael

+0

我对登录模块并不熟悉,但很少有LDAP实现会返回一个userPassword值,他们不应该这样做。 – jwilleke

回答

2

登录模块不应该尝试检索userPassword属性。 LDAP是一种身份验证协议,它有自己的方法来实现所谓的绑定。

Jetty的JAAS模块将尝试使用提供的凭据执行绑定,前提是您正确配置它。如果您在您的配置更改

forceBindingLogin="false" 

forceBindingLogin="true" 

那么它应该为你工作。