因為有需求需要把公司的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發送郵件