]> git.pld-linux.org Git - packages/git-core.git/blame - gitolite.pl
up to 2.30.0
[packages/git-core.git] / gitolite.pl
CommitLineData
c018688b 1# http://gitolite.com/gitolite/gitweb.conf.html
0328cfed
ER
2# ----------------------------------------------------------------------
3
4# Per-repo authorization for gitweb using gitolite v3 access rules
5# Read comments, modify code as needed, and include in gitweb.conf
6
7# ----------------------------------------------------------------------
8
9# First, run 'gitolite query-rc -a' (as the gitolite hosting user) to find the
10# values for GL_BINDIR and GL_LIBDIR in your installation. Then use those
11# values in the code below:
12
13BEGIN {
c018688b
ER
14 $ENV{HOME} = '/home/services/git'; # or whatever is the hosting user's $HOME
15 $ENV{GL_BINDIR} = '/usr/share/gitolite';
16 $ENV{GL_LIBDIR} = '/usr/share/gitolite/lib';
0328cfed
ER
17}
18
19# Pull in gitolite's perl API module. Among other things, this also sets the
20# GL_REPO_BASE environment variable.
21use lib $ENV{GL_LIBDIR};
22use Gitolite::Easy;
23
24# Set projectroot for gitweb. If you already set it earlier in gitweb.conf
25# you don't need this but please make sure the path you used is the same as
26# the value of GL_REPO_BASE in the 'gitolite query-rc -a' output above.
27$projectroot = $ENV{GL_REPO_BASE};
28
29# Now get the user name. Unauthenticated clients will be deemed to be the
30# 'gitweb' user so make sure gitolite's conf file does not allow that user to
31# see anything sensitive.
32$ENV{GL_USER} = $cgi->remote_user || 'gitweb';
33
34$export_auth_hook = sub {
35 my $repo = shift;
36 # gitweb passes us the full repo path; we need to strip the beginning and
37 # the end, to get the repo name as it is specified in gitolite conf
38 return unless $repo =~ s/^\Q$projectroot\E\/?(.+)\.git$/$1/;
39
40 # call Easy.pm's 'can_read' function
41 return can_read($repo);
42};
This page took 0.048252 seconds and 4 git commands to generate.