Git -lab集成AD域

先奉上Gitlad 与AD域集成,后续将继续奉上Nexus、Jenkinsyu AD域的集成记录。

如果您觉得有用请点个攒。

查询容器信息

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS                PORTS                                                      NAMES
6e64e00ea1c4        nginx:1.19                "/docker-entrypoint.…"   4 months ago        Up 7 days             0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp                   home_nginx_1
2963b288d9c1        jenkins/jenkins:lts       "/sbin/tini -- /usr/…"   4 months ago        Up 7 days             8080/tcp, 0.0.0.0:50000->50000/tcp                         home_jenkins_1
51fe3007b697        gitlab/gitlab-ce:latest   "/assets/wrapper"        4 months ago        Up 7 days (healthy)   80/tcp, 443/tcp, 0.0.0.0:2222->22/tcp                      home_gitlab_1
584b3e776dbd        sonatype/nexus3           "sh -c ${SONATYPE_DI…"   4 months ago        Up 7 days             0.0.0.0:8080->8080/tcp, 0.0.0.0:8082->8082/tcp, 8081/tcp   home_nexus_1

进入Git容器

[root@localhost ~]# docker exec -it 51fe3007b697 /bin/bash
root@git:/#

编辑git配置文件

root@git:/# vim /etc/gitlab/gitlab.rb

我的配置文件关于LDAP的配置大约在430行,供大家参考。也可以直接搜索,shift+? 输入:ldap_enabled,进行搜索定位,如果你使用的微软AD域,添加如下配置:
 

 gitlab_rails['ldap_enabled'] = true
 gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
   main: # 'main' is the GitLab 'provider ID' of this LDAP server
     label: 'AD域'
     host: '192.168.100.1'
     port: 389
     uid: 'cn'
     bind_dn: 'cn=admin,cn=Users,dc=xxxx,dc=com'
     password: 'zxhN*XXASASARFGGGx*!3Kxt'
     encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
     verify_certificates: true
     smartcard_auth: false
     active_directory: true
     allow_username_or_email_login: true
     lowercase_usernames: false
     block_auto_created_users: false
     base: 'ou=产品研发中心,dc=xxxx,dc=com'
     user_filter: ''
     ## EE only
     group_base: ''
     admin_group: ''
     sync_ssh_keys: false

其中的 label: 'AD域' 定义了登录页的标题,可以按需修改,效果如下图:

重载配置文件:

gitlab-ctl reconfigure

看到如下提示,标识顺利完成

Running handlers:
Running handlers complete
Chef Infra Client finished, 4/742 resources updated in 14 seconds
gitlab Reconfigured!

重启git服务

gitlab-ctl restart

测试ad配置

root@git:/# gitlab-rake gitlab:ldap:check
Checking LDAP ...

LDAP: ... Server: ldapmain
LDAP authentication... Success
LDAP users with access to your GitLab server (only showing the first 100 results)
        DN: cn=test1,ou=产品研发中心,dc=xxxx,dc=com        cn: test1
        DN: cn=gittest,ou=产品研发中心,dc=xxxx,dc=com      cn: gittest
        DN: cn=test,ou=产品研发中心,dc=xxxx,dc=com         cn: test

Checking LDAP ... Finished

回到git登录页面使用测试账户登录,成功。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值