summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien Thebo <adrien@puppetlabs.com>2012-03-19 01:02:00 -0700
committerAdrien Thebo <adrien@puppetlabs.com>2012-03-19 01:02:00 -0700
commit2f51dc75dd9b83831a89a4e3afc8df0543d8b37b (patch)
tree01578b9f96b63185152e5b1e15f04fa6a5e64a31
parent4c29ceba05f70f9f5dc7d864c986ba2bf0f80c4e (diff)
correct links, add gitolite integration
-rw-r--r--templates/gitweb.conf.erb53
1 files changed, 49 insertions, 4 deletions
diff --git a/templates/gitweb.conf.erb b/templates/gitweb.conf.erb
index 366c3ce..04b2dca 100644
--- a/templates/gitweb.conf.erb
+++ b/templates/gitweb.conf.erb
@@ -11,13 +11,58 @@ $git_temp = "/tmp";
$home_text = "indextext.html";
# file with project list; by default, simply scan the projectroot dir.
-$projects_list = "<%= projects_list %>";
+$projects_list = $projectroot;
# stylesheet to use
-$stylesheet = "/gitweb/gitweb.css";
+$stylesheet = "/gitweb.css";
# logo to use
-$logo = "/gitweb/git-logo.png";
+$logo = "/git-logo.png";
# the 'favicon'
-$favicon = "/gitweb/git-favicon.png";
+$favicon = "/git-favicon.png";
+
+# --------------------------------------------
+# Per-repo authorization based on gitolite ACL
+# Include this in gitweb.conf
+# See doc/3-faq-tips-etc.mkd for more info
+
+# HOME of the gitolite user
+my $gl_home = $ENV{HOME} = "/home/git";
+
+# the following variables are needed by gitolite; please edit before using
+
+# this should normally not be anything else
+$ENV{GL_RC} = "$gl_home/.gitolite.rc";
+# this can have different values depending on how you installed.
+
+$ENV{GL_BINDIR} = "/usr/share/gitolite";
+# If in doubt take a look at ~/.ssh/authorized_keys; at least one of the lines
+# might contain something like:
+# command="/home/git/.gitolite/src/gl-auth-command
+# and you should use whatever directory the gl-auth-command is in (in this
+# example /home/git/.gitolite.src)
+
+# finally the user name
+$ENV{GL_USER} = $cgi->remote_user || "gitweb";
+
+# now get gitolite stuff in...
+unshift @INC, $ENV{GL_BINDIR};
+#require gitolite_rc; gitolite_rc -> import;
+require gitolite; gitolite -> import;
+
+# set project root etc. absolute paths
+$ENV{GL_REPO_BASE_ABS} = $projectroot;
+
+$export_auth_hook = sub {
+ my $repo = shift;
+ print "projects_list: $projects_list\n";
+ # gitweb passes us the full repo path; so we strip the beginning
+ # and the end, to get the repo name as it is specified in gitolite conf
+ return unless $repo =~ s!^\Q<%= project_root %>\E\/?(.+)\.git$!$1!;
+
+ # check for (at least) "R" permission
+ my ($perm, $creator) = &repo_rights($repo);
+ print STDERR "user: $ENV{GL_USER} repo: $repo perms: $perm creator: $creator thing \n";
+ return ($perm =~ /R/);
+};