gpt4 book ai didi

apache - 仅在用户可以通过 Gitolite 访问的 gitweb 中显示 repos

转载 作者:行者123 更新时间:2023-12-04 18:06:30 24 4
gpt4 key购买 nike

我有 gitolite 设置并使用基于 SSH key 的身份验证。我可以通过 gitolite-admin.git 存储库和 conf 文件控制对存储库的访问。所有这些在 SSH 上运行良好,但我想使用 GitWeb 作为查看存储库的快速方式。

GitWeb 现在运行良好,但通过网络界面显示所有存储库。所以我的目标是:

  • 通过 PAM 在 apache2 中验证用户,我已经有 Ubuntu 服务器验证 aginst AD 并且所有用户都可用。这应该不是问题。
  • 使用检查gitolite权限的用户名登录
  • 在网络界面中显示适当的 REPOS。

有人有这方面的起点吗? Apache 部分应该不难,我会将其设置为对/gitweb/url 的所有内容进行身份验证。我不知道如何传递该用户名并针对 gitolite 授权它。有什么想法吗?

谢谢,

内森

最佳答案

是的,这是可能的,但你需要完成 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;
#$ENV{GL_USER} = $cgi->remote_user || "gitweb";

$export_auth_hook = sub {
my $repo = shift;
my $user = $ENV{GL_USER};
# 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$projectroot\E\/?(.+)\.git$/$1/;

# check for (at least) "R" permission
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会挑环境REMOTE_USER由任何已完成身份验证的 Apache Auth 模块设置(如 Apache configuration file 中所示)。
你可以打印出来with a 'die' line .

“找不到 Gitolite/Rc.pm”表示 perl 使用的 INC 变量不包含 $ENV{GL_LIBDIR}; (设置为 ~/gitolite/lib<any_place_where_gitolite_was_installed>/lib )。
这就是为什么有一行 in the same gitweb/gitweb.conf.pl 将其添加到 INC 的文件:

unshift @INC, $ENV{GL_LIBDIR};
use lib $ENV{GL_LIBDIR};
use Gitolite::Rc;

来自 Nat45928 的编辑:在我的例子中,我需要将我的主路径插入到所有“@H@”条目中。这立即解决了我所有的问题。

关于apache - 仅在用户可以通过 Gitolite 访问的 gitweb 中显示 repos,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25248162/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com