因为有需求需要把公司的LDAP接入到Gitlab中,此文档做为记录
gitlab已经安装安装好电梯直达
配置ldap
- 找到gitlab的gitlab.rb文件挂载位置,编辑gitlab.rb文件
...... #修改一下配置 gitlab_rails['ldap_enabled'] = true ###! **remember to close this block with 'EOS' below** gitlab_rails['ldap_servers'] = YAML.load <<-'EOS' main: # 'main' is the GitLab 'provider ID' of this LDAP server label: 'LDAP' host: 'XXX.XXX.XXX.XXX' #ldap服务器IP地址 port: 10389 #ldap端口 uid: 'cn' bind_dn: 'uid=Admin,ou=users,ou=system' #管理员登录用户名 password: 'password' #登录密码 encryption: 'plain' # "start_tls" or "simple_tls" or "plain" verify_certificates: true smartcard_auth: false active_directory: false # 如果是 Active Directory LDAP server 则设为true allow_username_or_email_login: true # 是否允许email登录 lowercase_usernames: false # 是否将用户名转为小写 block_auto_created_users: false # 是否自动创建用户 base: 'dc=redcollar,dc=com' #从哪个位置搜索用户 user_filter: '' #添加过滤属性 attributes: username: ['cn'] #用户名 email: ['email'] name: 'cn' first_name: 'givenName' #姓名 对应gitlab的name last_name: 'sn' # ## EE only # group_base: '' # admin_group: '' # sync_ssh_keys: false EOS #
- 配置完成后重启gitlab
docker restart gitlab
- 检查是否配置成功
docker exec -it gitlab /bin/bash root@git:/# gitlab-rake gitlab:ldap:check #列出前100个用户 Checking LDAP ... LDAP: ... Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) DN: cn=XXX,ou=XXX,dc=XXX,dc=XXX cn: XXXX ...... Checking LDAP ... Finished
显示以上内容说明配置成功
登录配置
如图:输入ldap用户名和密码
登录后修改相关信息 需要配置邮箱发邮件进行验证,不然没办法做任何操作。前提是你的gitlab必须配置了SMTP发送邮件