I would like to introduce access control to cgit once the cgi of cgit has been launched. The idea would be to list all the repos available in gitolite but enable/disable the directory listing based on user authentication.
I managed to get access control before apache is executing the cgit cgi:
AllowOverride None
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /var/lib/git_alfonso/passwords
Options +ExecCGI
Order allow,deny
Allow from all
Alias /cgit.png /var/www/htdocs/cgit/cgit.png
Alias /cgit.css /var/www/htdocs/cgit/cgit.css
ScriptAlias /cgit "/var/www/htdocs/cgit/cgit.cgi"
RewriteRule ^$ / [R]
RewriteRule ^/(.*)$ /cgit.cgi/$1****
But I don't know how to get the same effect once the repositories paths are accessed, I tried with the directory directive and adding the authentication there but once cgit is launched apache doesn't apply any other directive stated in the http.conf file.
Any clue on how to achieve it?
Thanks a lot in advance.
Br Alfonso.
I have done precisely that in my own cgit config.
(The @xx@ are template placeholder for values)
The idea is to wrap
cgit.cgi
with a custom scriptcgit.pl
(here a perl script but you can use any other scripting language you want), which will:You can see the full
cgit.pl
script here.This is when you are trying to access to a specific repo:
This is when you are calling cgit without a repo: it should list only the repos you are authorized to see.
For that, call the native
cgit.cgi
, and then filter the output, removing any line corresponding to a "denied" repo: