是的,这是可能的,但您需要完成gitweb配置脚本以调用gitolite。
关键在于
gitweb_config.perl
文件:如果该文件存在,gitweb将包含并调用它。
请参阅我的
gitweb/gitweb_config.perl
文件:
our $home_link_str = "ITSVC projects";
our $site_name = "ITSVC Gitweb";
use lib (".");
require "gitweb.conf.pl";
在
gitweb/gitweb.conf.pl
(自定义脚本)中,我定义了由gitweb调用的官方回调函数:
export_auth_hook
:该函数将调用gitolite。
use Gitolite::Common;
use Gitolite::Conf::Load;
$export_auth_hook = sub {
my $repo = shift;
my $user = $ENV{GL_USER};
return unless $repo =~ s/^\Q$projectroot\E\/?(.+)\.git$/$1/;
my $ret = &access( $repo, $user, 'R', 'any' );
my $res = $ret !~ /DENIED/;
return ($ret !~ /DENIED/);
};
从评论中可以看出:
GL_USER
是由以下代码行设置的:
$ENV{GL_USER} = $cgi->remote_user || "gitweb";
$cgi->remote_user
会获取由任何已完成身份验证的Apache Auth模块设置的环境变量REMOTE_USER
(就像在Apache配置文件中一样)。
您可以使用"die"语句打印它。
"
\"Could not find Gitolite/Rc.pm\"的意思是perl使用的INC变量中不包含$ENV{GL_LIBDIR};(设置为~/gitolite/lib
或<any_place_where_gitolite_was_installed>/lib
)。
这就是为什么有一行在同一个gitweb/gitweb.conf.pl
文件中将其添加到INC
中的原因:
"
unshift @INC, $ENV{GL_LIBDIR};
use lib $ENV{GL_LIBDIR};
use Gitolite::Rc;
从Nat45928编辑:在我的情况下,我需要将我的主目录插入到所有的'@H@'条目中。这立即解决了我的所有问题。
$ENV{GL_USER} = $cgi->remote_user || "gitweb";
这一行代码:认证应该在调用 gitweb 之前由 Apache 完成:请参见 https://github.com/VonC/compileEverything/blob/c1ec1e4bb4dedea93bc251d8395c9c7627c08440/apache/env.conf.tpl#L99-L134:最后一行调用了 gitwebDirectoryIndex gitweb.cgi
。 - VonC$cgi->remote_user
将包含$REMOTE_USER
的内容。我通常设置一些 die 调试行来检查它的内容,例如 https://github.com/VonC/compileEverything/blob/c1ec1e4bb4dedea93bc251d8395c9c7627c08440/gitweb/gitweb.conf.pl.tpl#L17 - VonC