2014-01-16 278 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" 

那麼它應該爲你工作。