接上一篇,Freeipa接完confluence,接下来是接入Gitlab.
先下结论:同样道理,也是存在先有 Gitlab 账户、然后才有的 FreeIPA LDAP 目录,这也不要紧,因为 Gitlab 同样支持 LDAP 认证方式的用户与现有用户进行合并。
举个例子,如果我已经在 Gitlab 中创建了用户名为 zhangranrui、邮箱为 zhangranrui@rendoumi.com 的用户,那么我在 LDAP 目录中只需要把 mail 字段也写成 zhangranrui@rendoumi.com 即可被 Gitlab 识别成同一用户。或者说,我们可以在 Gitlab 中增加 LDAP 目录中的 mail 字段的邮箱(Gitlab 支持同一用户绑定多个邮箱),这样在 Gitlab 中使用 LDAP 认证的时候也会被视为同一用户。跟 Confluence 是一模一样的。
注意:这样改了之后,无论登录或是拉取代码,就只能使用LDAP的账号密码,不能使用旧的 GitLab Standard 的账号。
我们的 Gitlab 版本比价老11.1.0,所以改的是 gitlab.yml
ldap:
enabled: true
servers:
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'LDAP'
host: 'freeipa.bybon.cn'
port: 389
uid: 'uid'
encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
verify_certificates: false
ca_file: ''
ssl_version: ''
bind_dn: 'uid=admin,cn=users,cn=accounts,dc=bybon,dc=cn'
password: 'xxxxxx'
timeout: 10
active_directory: false
allow_username_or_email_login: false
block_auto_created_users: false
base: 'dc=bybon,dc=cn'
user_filter: '(&(objectclass=inetorgperson)(memberOf=cn=gitlab-users,cn=groups,cn=accounts,dc=bybon,dc=cn))'
attributes:
username: ['uid']
email: ['mail']
name: 'displayName'
first_name: 'givenName'
last_name: 'sn'
lowercase_usernames: false
新版本的话,按字段比较即可。注意上面,我是提前建立了一个 gitlab-users 的组,把用户先都放进组里,这样方便管理。