1

在我自己托管的 GitLab CE 安装中,有一个 Explore 链接,这样就可以为没有登录的用户提供读取权限。我怎样才能禁用它?

4

3 回答 3

1

您无法禁用此链接,但可以将其重定向回匿名用户的登录页面。

cd /opt/gitlab/embedded/service/gitlab-rails/app/controllers/
sudo cp application_controller.rb application_controller.rb.orig
sudo vim application_controller.rb

并将以下代码片段添加到 application_controller.rb

...
 before_action :force_authenticated_user!
...
def force_authenticated_user!(*args)
    if (!current_user) and (["/explore", "/help", "/public", "/users/password/new", "/users/password/edit"].include?(request.path))
        redirect_to new_user_session_path and return
    end
end
...

或所有路径的更好方法(带有子目录):

...
 before_action :force_authenticated_user!
...
def force_authenticated_user!(*args)
     if (!current_user) and (["/users/sign_in", "/users/password","/uploads/-/system/appearance/header_logo/1/your_logo.PNG","/users/auth/ldapmain/callback"].exclude?(request.path))
            redirect_to new_user_session_path and return
    end
end
...
于 2018-05-09T20:26:49.957 回答
1

我认为您必须将项目的可见性设置为私有或内部。除此之外,我认为存储库应该配置为仅供我的团队成员查看,以获得额外的安全层。

这些是我在那里托管的一些项目的设置,它们没有出现在“探索”部分。您可以在Settings每个项目的选项卡中检查它们。

在此处输入图像描述

于 2017-04-06T10:09:00.050 回答
1

如果您希望仍然拥有“探索”部分,但又想阻止外部用户克隆项目,那么您需要将这些项目设置为Internal可见级别。

以下是不同可见度级别的摘要。作为管理员,您可以限制项目被设置为Public并且只允许PrivateInternal级别。

于 2017-04-06T10:19:11.463 回答