gitlab配置LDAP
一、接入openldap
1.1 修改配置文件gitlab.rb
在gitlab.rb文件中添加下面配置,其中:
1.host,是搭建的openldap的ip,根据实际情况修改;
2.uid,可以配置cn,也可以配置uid,都能识别(具体为什么没深入研究);
3.bind_dn,openldap的管理员账号,根据实际情况修改;
4.password,openldap的管理员,根据实际情况修改;
5.active_directory,似乎是针对连接是否是ad域控的标示,因为这部分是openldap的配置,故为false;
6.allow_username_or_email_login,用户登录是否用户名和邮箱都可以,方便用户故配置true;
7.base,用户列表所在的目录,因为新增的用户都在openldap的People下,故这么配置,根据实际情况修改;
指明服务的地址
external_url = ‘http://localhost’
开启ldap
257 gitlab_rails['ldap_enabled'] = true
258
259 ###! **remember to close this block with 'EOS' below**
260 gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
261 main: # 'main' is the GitLab 'provider ID' of this LDAP server
262 label: 'LDAP' #
263 host: '192.168.13.189'
264 port: 389
265 uid: 'sAMAccountName'
266 method: 'plain'
267 bind_dn: 'cn=Administrator,cn=Users,dc=hongte,dc=info'
268 password: '!@1234qwe'
269 # encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
270 # verify_certificates: true
271 # smartcard_auth: false
272 active_directory: true
273 allow_username_or_email_login: false
274 # lowercase_usernames: false
275 block_auto_created_users: false
276 base: 'ou=鸿特信息,dc=hongte,dc=info'
277 user_filter: ''
278 # ## EE only
279 # group_base: ''
280 # admin_group: ''
281 # sync_ssh_keys: false
282 #
283 # secondary: # 'secondary' is the GitLab 'provider ID' of second LDAP server
284 # label: 'LDAP'
285 # host: '_your_ldap_server'
286 # port: 389
287 # uid: 'sAMAccountName'
288 # bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
291 # verify_certificates: true
292 # smartcard_auth: false
293 # active_directory: true
294 # allow_username_or_email_login: false
295 # lowercase_usernames: false
296 # block_auto_created_users: false
297 # base: ''
298 # user_filter: ''
299 # ## EE only
300 # group_base: ''
301 # admin_group: ''
302 # sync_ssh_keys: false
303 EOS
1.2 重新加载新配置
gitlab-ctl reconfigure
运行后最后一行为“gitlab Reconfigured!”才说明是加载新配置成功,否则就是根据报错信息找错误。
1.3 查看是否能正常获取用户列表
gitlab-rake gitlab:ldap:check
正常连接的情况下执行之后能看到用户的列表
1.4 重启gitlab
gitlab-ctl restart
二、接入AD
2.1 修改配置文件gitlab.rb
在gitlab.rb文件中添加下面配置,其中:
1.host,是搭建的微软域服务器的ip,根据实际情况修改;
2.uid,必须配sAMAccountName才能识别;
3.bind_dn,域服务器的管理员账号,根据实际情况修改;
4.password,域服务器的管理员,根据实际情况修改;
5.active_directory,似乎是针对连接是否是ad域控的标示,因为这部分是域服务器的配置,故为true;
6.allow_username_or_email_login,用户登录是否用户名和邮箱都可以,方便用户故配置true;
7.base,用户列表所在的目录,因为新增的用户都在People下(试验了用户放在User时gitlab检测不到用户,故新建了一个目录People,并将新建的用户移入了该目录下),故这么配置,根据实际情况修改;
external_url = ‘http://localhost’
gitlab_rails[‘ldap_enabled’] = true
gitlab_rails[‘ldap_servers’] = YAML.load <<-‘EOS’ ###! remember to close this block with ‘EOS’ below
main: # ‘main’ is the GitLab ‘provider ID’ of this LDAP server
label: ‘LDAP’
host: ‘192.168.6.1’
port: 389
uid: ‘sAMAccountName’
method: ‘plain’ # “tls” or “ssl” or “plain”
bind_dn: ‘cn=Administrator,cn=users,dc=myad,dc=cn’
password: ‘123456’
active_directory: true
allow_username_or_email_login: true
block_auto_created_users: false
base: ‘ou=People,dc=myad,dc=cn’
user_filter: ‘’
EOS
2.2 重新加载新配置
gitlab-ctl reconfigure
运行后最后一行为“gitlab Reconfigured!”才说明是加载新配置成功,否则就是根据报错信息找错误。
2.3 查看是否能正常获取用户列表
gitlab-rake gitlab:ldap:check
正常连接的情况下执行之后能看到用户的列表
2.4 重启gitlab
gitlab-ctl restart
作者:Bin Xiao
来源:优快云
原文:https://blog.youkuaiyun.com/xiaohuibin0541/article/details/83688307
版权声明:本文为博主原创文章,转载请附上博文链接!