Search code examples
jenkinsldapphabricator

How to config phabricator login use ldap?


I have already migrate Jenkins to use LDAP login, and have no problem. But when I tried to migrate phabricator to use LDAP, I got "Username or password are incorrect." every time, and I'm sure the same username and passwd can login Jenkins. I was using the same OpenLDAP server, and the LDAP has a readonly DN: cn=readonly,dc=my-company,dc=com. Phabricator configurations list below:

Allow: "Allow Login"
LDAP Hostname & Port: exactly the same with my Jenkins configuration
Base Distinguished Name: ou=user,dc=my-company,dc=com (while Jenkins root DN was dc=my-company,dc=com)
Search Attributes: empty
Always Search: unchecked
Anonymous Username: cn=readonly, dc=my-company, dc=com (same with Jenkins Manager DN)
Anonymous Password: the password (same with Jenkins Manager password)
Username Attribute: uid
Realname Attributes: empty
LDAP Version: 3

This has block me two days, is there something I missed?

Thanks for your answer~


Solution

  • Oh, I figure it out. Phabricator has a different LDAP login mechanism with Jenkins. Phabricator always bind LDAP with the user's DN and password (to verify login), then search the user's DN itself. Below is the comment in the LDAP login code:

      // This is unusual (since the bind succeeded) but we've seen it at least
      // once in the wild, where the anonymous user is allowed to search but
      // the credentialed user is not.
    
      // If we don't have anonymous credentials, raise an explicit exception
      // here since we'll fail a typehint if we don't return an array anyway
      // and this is a more useful error.
    
      // If we do have anonymous credentials, we'll rebind and try the search
      // again below. Doing this automatically means things work correctly more
      // often without requiring additional configuration.
    

    So, LDAP users must have search acl, like:

      olcAccess: {1}to * 
        by self write 
        by dn="cn=admin,dc=my-company,dc=com" write 
        by dn="cn=readonly,dc=my-company,dc=com" read  
        by users search 
        by * none
    

    I didn't have 'by users search' option, so login failed.