Ldap – Automatic LDAP login to Gitlab

apache-2.2gitlabldapopenldap

I've Apache 2.2 and Gitlab 6 running. After installing OpenLDAP on Debian Wheezy and setting up Gitlab I can login to Gitlab with LDAP credentials. But I wonder if there is a way to provide LDAP login credentials from Apache 2.2 Basic Auth to Gitlab. When enabled in Apache and in Gitlab I have to login twice, nevertheless. (I will need this behaviour also for Mantis)

EDIT
I made a wrong assumption. When authenticating to Apache with LDAP, this is a HTTP Basic Auth, nevertheless. So Gitlab has to accept Basic Auth credentials (HTTP_REMOTE_USER) from Apache to login user based on Gitlabs own user database. As far as I've seen, there are some efforts, but this patch is only for Gitlab 6 (I'm using version 6.2). And as you can read in next-to-last comment here, it seems, that Gitlab will develop such a function for Enterprise version.

Best Answer

I have been having the very same problem. I wanted to authenticate through kerberos/AD and the authenticated user uses the LDAP attributes. Apache gets its credentials and sets the HTTP_REMOTE_USER and forward it to unicorn which does not know what to do with it. The solution is to force the forwarding of this variable in header, to let unicorn retrieves it, and then gitlab does the job.

RewriteEngine On
RewriteCond %{LA-U:REMOTE_USER} (.*)
RewriteRule . - [E=RU:%1,NS]
RequestHeader set REMOTE_USER "%{RU}e" env=RU

You may want to look at my problem which would provide more information. Currently, this is not (unfortunately) solved in my case implying Kerberos :/ But for your case it should work.