Gitlab 11.0.3漢化完成后,需要集成域控,現將域控的配置過程描述如下:
gitlab目錄:/etc/gitlab
gitlab配置文件:/etc/gitlab/gitlab.rb
編輯gitlab.rb文件:
在gitlab.rb文件中修改下面配置,其中:
1.host,是搭建的ldap的ip,根據實際情況修改;
2.uid,可以配置cn,也可以配置uid,都能識別(具體為什么沒深入研究);
3.bind_dn,ldap的管理員賬號,根據實際情況修改;
4.password,ldap的管理員,根據實際情況修改;
5.active_directory,似乎是針對連接是否是ad域控的標示,因為這部分是ldap的配置,故為false;
6.allow_username_or_email_login,用戶登錄是否用戶名和郵箱都可以,方便用戶故配置true;
7.base,用戶列表所在的目錄,因為新增的用戶都在ldap的People下,故這么配置,根據實際情況修改;
我的配置如下:
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: '**.**.**.**'
port: 389
uid: 'sAMAccountName'
bind_dn: 'cn=***,cn=Users,dc=***,dc=****,dc=COM'
password: '*****'
encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
verify_certificates: true
active_directory: true
allow_username_or_email_login: true
lowercase_usernames: false
block_auto_created_users: false
base: 'OU=Users,OU=*****,DC=***,DC=*****,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
# 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
重要配置參數解釋(仔細閱讀上一篇svn集成LDAP認證的文章這些參數會更好理解):
- host:LDAP服務器地址
- port:LDAP服務端口
- uid:以哪個屬性作為驗證屬性,可以為uid、cn等,我們使用uid
- method:如果開啟了tls或ssl則填寫對應的tls或ssl,都沒有就填寫plain
- bind_dn:search搜索賬號信息的用戶完整bind(需要一個有read權限的賬號驗證通過后搜索用戶輸入的用戶名是否存在)
- password:bind_dn用戶的密碼,bind_dn和password兩個參數登錄LDAP服務器搜索用戶
- active_directory:LDAP服務是否是windows的AD,我們是用的OpenLDAP,這里寫false
- allow_username_or_email_login:是否允許用戶名或者郵箱認證,如果是則用戶輸入用戶名或郵箱都可
- base:從哪個位置搜索用戶,例如允許登錄GitLab的用戶都在ou gitlab里,name這里可以寫ou=gitlab,dc=domain,dc=com
- filter:添加過濾屬性,例如只過濾employeeType為developer的用戶進行認證(employeeType=developer)
配置完成后進行配置更新:
gitlab-ctl reconfigure
檢查是否配置成功:
gitlab-rake gitlab:ldap:check(列出前100個用戶)
重啟gitlab服務:
gitlab-ctl restart
注意: 確認該用戶不處於特殊狀態
1.不處於“禁用賬戶”的狀態;
2.不處於“需要首次登錄修改密碼”的狀態;
(處於上面任意一種狀態的賬戶在登錄gitlab時都會報“Cloud not authenticate you from Ldapmain because "Invalid creadentials".”)
下圖是發出的search 用戶狀態的請求:
判斷用戶狀態碼:
https://www.cnblogs.com/tldxh/p/7093360.html