gitlab配置ldap登录
经海路小霸王 -打开gitlab在linux上的默认安装路径
vim /etc/gitlab/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: 'localhost'
port: 389
uid: 'uid'
bind_dn: 'cn=admin,dc=zdpoc,dc=com'
password: '666666'
encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
# verify_certificates: true
# smartcard_auth: false
active_directory: true
allow_username_or_email_login: false
# lowercase_usernames: false
# block_auto_created_users: false
base: 'ou=people,dc=zdpoc,dc=com'
user_filter: ''
# ## EE only
# group_base: ''
# admin_group: ''
# sync_ssh_keys: false
#
# secondary: # 'secondary' is the GitLab 'provider ID' of second LDAP server
# label: 'LDAP'
# host: '_your_ldap_server'
# port: 389
# uid: 'sAMAccountName'
# bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
# password: '_the_password_of_the_bind_user'
# encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
# verify_certificates: true
# smartcard_auth: false
# active_directory: true
# allow_username_or_email_login: false
# lowercase_usernames: false
# block_auto_created_users: false
# base: ''
# user_filter: ''
# ## EE only
# group_base: ''
# admin_group: ''
# sync_ssh_keys: false
EOS
必须按照上述示例启用字段,不要以为注释里的就是默认的,要不然 GitLab 会报 500 错误, 例如
active_directory: true``host
和 port
是 LDAP 服务的主机地址及端口bind_dn
和 password
是一个管理 LDAP 的 dn 及密码,需要有管理员权限,对应着 LDAP 服务的顶级域和密码base
表示 LDAP 将以该 dn 为 节点,向下查找用户user_filter
表示以某种过滤条件筛选用户,比如假设我们只希望所属组为 Developers 的用户来访问 GitLab,则可以在这里设置 (memberOf=cn=Developers,cn=Groups,dc=xinhua,dc=org)
attributes
表示 GitLab 中的字段与 LDAP 中哪些字段可以相互对应uid表示gitlab的登录名,对应ldap中用户的哪个参数配置完后重启服务 gitlab-ctl reconfigure
可通过 gitlab-rake gitlab:ldap:check 校验配置是否成功,成功返回如下图(需重启后校验)
特别申明:本文内容来源网络,版权归原作者所有,如有侵权请立即与我们联系(cy198701067573@163.com),我们将及时处理。
上一篇: 一款可以实现私有化部署的企业级知识库!