gitlab搭建与认证登录

gitlab的安装配置

参考链接: Gitlab 仓库搭建(详细版)

以下4项注意点:

  1. gitlab安装包,直接访问在浏览器上下载速度很慢,可复制链接到迅雷中进行下载
    https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.0.0-ce.0.el7.x86_64.rpm

  2. 这些gitlab需要的依赖包不能少
    yum install -y curl policycoreutils-python openssh-server openssh-clients

  3. 如果开了防火墙,还需把gitlab的端口打开(我这里设置的是9091)
    firewall-cmd --zone=public --add-port=9091/tcp --permanent

  4. 访问gitlab时记得是使用http://ip地址:9091 而不是https

gitlab中Ldap认证配置

Ldap的安装与配置请看之前的文章: LDAP配置与安装

我这里Ldap服务器的ip地址是:192.168.9.128 端口:389(测试用)
Ldap中用户、组的架构如下图所示:

下面的配置,参考自:https://www.php.cn/faq/506412.html

  • 添加配置

vim /etc/gitlab/gitlab.rb

gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
main: # 'main' is the GitLab 'provider ID' of this LDAP server
    label: 'LDAP'
    host: '192.168.9.128'
    port: 389
    uid: 'uid'
    method: 'plain' # "tls" or "ssl" or "plain" # 加密方式
    bind_dn: 'cn=admin,dc=ss,dc=com'			# Ldap管理员账号
    password: '123456' 							# Ldap管理员密码
    active_directory: false
    allow_username_or_email_login: true
    block_auto_created_users: false				# 是否阻止自动创建
    base: 'ou=People,dc=ss,dc=com'				# 查询的基础DN
    # user_filter: '(memberOf=cn=gitlab,ou=gitlab,dc=ss,dc=com)'	# 过滤条件筛选用户,这里让gitlab组的成员可以访问使用
    attributes:
       username: ['uid', 'userid', 'sAMAccountName']
       email: ['mail', 'email', 'userPrincipalName']
       name: 'cn'
       first_name: 'givenName'
       last_name:  'sn'
EOS

配置完之后,重新执行GitLab的配置
gitlab-ctl reconfigure

  • 测试
    重新访问gitlab登录页面,会发现增加了LDAP登录的选项
    使用ldap用户登录后,可以在gitlab管理员root账号下看到已经新添了成员:caiwu1
    (提示:如果重新登录gitlab出现报错422,烦请删除浏览器缓存或更换其他浏览器再去访问!)

至此,gitlab中Ldap认证配置完成。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值