gitlab配置LDAP認證和SMTP


配置LDAP認證 (實驗環境LDAP認證服務器類型為Microsoft AD)

編輯 /etc/gitlab/gitlab.rb配置文件:

### LDAP Settings
###! Docs: https://docs.gitlab.com/omnibus/settings/ldap.html
###! **Be careful not to break the indentation in the ldap_servers block. It is
###!   in yaml format and the spaces must be retained. Using tabs will not work.**

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: 'LDAP server IP'
     port: 389
     uid: 'sAMAccountName'
     bind_dn: 'bindDN'  #有查詢權限的用戶DN
     password: 'password'
     encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
     verify_certificates: true
     smartcard_auth: false
     active_directory: true
     allow_username_or_email_login: true
     lowercase_usernames: false
     block_auto_created_users: false
     base: 'baseDN'
     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-ctl reconfigure #重載配置文件

gitlab-rake gitlab:ldap:check #檢查是否能夠正常獲取用戶信息

gitlab-ctl restart重啟后重新登錄gitlab,登錄頁面會有LDAP方式:

 

 

 

SMTP配置 (實驗環境中SMTP server類型為Microsoft Exchange)

編輯 /etc/gitlab/gitlab.rb配置文件:

### GitLab email server settings
###! Docs: https://docs.gitlab.com/omnibus/settings/smtp.html
###! **Use smtp instead of sendmail/postfix.**

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "mail server"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "smtp user" # SMTP認證用戶名
gitlab_rails['smtp_password'] = "smtp user password"
gitlab_rails['smtp_domain'] = "domain"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_openssl_verify_mode'] = 'none' #報openssl錯誤時,啟用此選項
# gitlab_rails['smtp_tls'] = false

修改配置完成后

gitlab-ctl reconfigure #重載配置文件

gitlab-rails console進入控制台,發送測試郵件: Notify.test_email('receiver mail', 'title', 'content').deliver_now

如果出現如下SMTP權限錯誤,SMTPFatalError (550 5.7.60 SMTP; Client does not have permissions to send as this sender)

可能是SMTP server上的防垃圾郵件限制,此時需要在配置文件加上sender mail地址,確保smtp驗證用戶名和sender是一致的。

 gitlab_rails['gitlab_email_enabled'] = true
 gitlab_rails['gitlab_email_from'] = 'sender address'  #sender address和上段smtp認證用戶名配置一致
 gitlab_rails['gitlab_email_display_name'] = 'xxx'
 gitlab_rails['gitlab_email_reply_to'] = ''


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM