Only show GIT repo's to which user has access with gitweb
I currently am experimenting with setting up a GIT repository server so we can switch from SVN to GIT. I've got almost everything covered, but am left with an issue.
The current setup is as follows:
- All developers (and non-developers) have a user accounts & correct groups because the server is a NIS client
- All repos are made in /var/git/
- All pulling/pushing is done over ssh
This works perfectly so far, and eliminates the need for gitosis or gitolite.
Because I would like to have a browsable overview of the repositories I've set up gitweb including pathinfo. Because the repos are private I've set up authentication through Perl AuthenNIS and this works, but here I encounter a problem.
It is undesired that all developers have access to all repositories, but gitweb just shows every repository it (the apache user) can read.
So my question is: is it possible to make gitweb only show the GIT repo's the currently logged in user has access to?
Possible solutions:
- Further access control through .htaccess. The pathinfo would enable this b开发者_开发百科ut it wouldn't prevent the repo's from being accessed through non-pathinfo URLs (e.g. /repo.git/ wouldn't work but /gitweb.cgi?p=repo.git would)
- Setting up a full gitosis/gitolite environment and integrating it into gitweb (essentially this). I would like to prevent this because the overhead is undesirable
- Making gitweb run as the authenticated HTTP user. This would fix all the access control problems but I don't know how to do this
- gitweb's
$export_auth_hook
in combination with$cgi->remote_user
seems promising, but my understanding of perl is too limited to use it (the hook would need to verify that the user has permission to access the repo directory before showing/exporting it)
Is there anyone who knows how to make 3 or 4 work or has another solution?
If developers are pushing/pulling from the repository server using ssh under (I presume) their own user names, then perhaps the easiest way to accomplish what this is to find a way to run gitweb
or git
under that user's identity.
For instance, find a way to add an authentication hook before gitweb
is executed. Then add a wrapper around gitweb
that executes sudo -u $user gitweb.real
where $user
is the authenticated user name.
Or, you could just wrap the git
command, i.e. have gitweb
execute a wrapper which does a sudo -u $user {real-git-path}
.
For implementing authentication against NIS/PAM in Apache, have a look at mod_auth_external
精彩评论