apache - Access control in Cgit -
i introduce access control cgit once cgi of cgit has been launched. idea list repos available in gitolite enable/disable directory listing based on user authentication.
i managed access control before apache executing cgit cgi:
allowoverride none authtype basic authname "restricted files" authuserfile /var/lib/git_alfonso/passwords options +execcgi order allow,deny allow
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 don't know how same effect once repositories paths accessed, tried directory directive , adding authentication there once cgit launched apache doesn't apply other directive stated in http.conf file.
any clue on how achieve it?
thanks lot in advance.
br alfonso.
i have done precisely in own cgit config.
# cgit on @port_http_cgit@ listen @port_http_cgit@ <virtualhost @fqn@:@port_http_cgit@> servername @fqn@ serveralias @hostname@ setenv git_http_backend "@h@/usr/local/apps/git/libexec/git-core/git-http-backend" documentroot @h@/cgit alias /cgit @h@/cgit <directory @h@/cgit> setenv git_project_root=@h@/repositories addhandler cgi-script .cgi .pl directoryindex cgit.pl
(the @xx@ template placeholder values)
the idea wrap cgit.cgi
custom script cgit.pl
(here perl script can use other scripting language want), will:
- call gitolite
- only display authorized gitolite
you can see full cgit.pl
script here.
this when trying access specific repo:
if ($request_uri ne "/cgit/" && $request_uri ne "/cgit/cgit.pl/") { (my $repo)=($path_info =~ /\/([^\/]+)/); $perm = "r"; if ($repo ne "") { $aperm = access( $repo, $user, 'r', 'any' ); # ($aperm, $creator) = &repo_rights($repo); $perm=$aperm; } if ($perm !~ /denied/) { system("@h@/cgit/cgit.cgi"); } }
this when calling cgit without repo: should list repos authorized see.
that, call native cgit.cgi
, , filter output, removing line corresponding "denied" repo:
$fname="$user.".timestamp().".tpl"; system("@h@/cgit/cgit.cgi > $fname"); open(info, $fname); # open file @lines = <info>; # read array close(info); unlink($fname); pop(@lines); foreach (@lines) { $line=$_; (my $repo)=($line =~ /title='([^']+)'/); #' $perm = "r"; if ($repo ne "") { $aperm = access( $repo, $user, 'r', 'any' ); # ($aperm, $creator) = &repo_rights($repo); $perm=$aperm; } if ($perm !~ /denied/) { print $line; } }
Comments
Post a Comment