直接修改配置文件
gitlab.yml
ldap:
enabled: true
servers:
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'LDAP'
host: '10.112.xx.xx'
port: 389 # usually 636 for SSL
uid: 'cn' # This should be the attribute, not the value that maps to uid.
bind_dn: 'cn=admin,dc=chegva,dc=com'
password: 'chegva.com'
encryption: 'plain'
verify_certificates: false
ca_file: ''
ssl_version: ''
timeout: 10
active_directory: true
allow_username_or_email_login: false
block_auto_created_users: false
base: 'dc=chegva,dc=com'
user_filter: ''
attributes:
username: ['uid', 'userid', 'sAMAccountName']
email: ['mail', 'email', 'userPrincipalName']
name: 'cn'
first_name: 'givenName'
last_name: 'sn'
重要配置参数解释(仔细阅读上一篇svn集成LDAP认证的文章这些参数会更好理解):
host
:LDAP服务器地址port
:LDAP服务端口uid
:以哪个属性作为验证属性,可以为uid、cn等,这里使用cnmethod
:如果开启了tls或ssl则填写对应的tls或ssl,都没有就填写plainbind_dn
:search搜索账号信息的用户完整bind(需要一个有read权限的账号验证通过后搜索用户输入的用户名是否存在)password
:bind_dn用户的密码,bind_dn
和password
两个参数登录LDAP服务器搜索用户active_directory
:LDAP服务是否是windows的AD,我们是用的OpenLDAP,这里写falseallow_username_or_email_login
:是否允许用户名或者邮箱认证,如果是则用户输入用户名或邮箱都可base
:从哪个位置搜索用户,例如允许登录GitLab的用户都在ou gitlab里,name这里可以写ou=gitlab,dc=domain,dc=com
filter
:添加过滤属性,例如只过滤employeeType为developer的用户进行认证(employeeType=developer)
重启GitLab服务,首页已经有LDAP的登录选项啦。
登陆查看用户信息:
查看配置:
omniauth:
enabled: true
allow_single_sign_on: ["saml", "cas3"]
block_auto_created_users: false
auto_link_ldap_user: false
auto_link_saml_user: false
external_providers: []
providers:
- { name: 'cas3',
label: 'cas',
args: {
host: 'cas.chegva.com',
disable_ssl_verification: true,
login_url: '/login',
service_validate_url: '/serviceValidate',
logout_url: '/logout'} }
重启gitlab,登陆用户查看信息:
当然也可以添加多种认证方式:
3. Gitlab Authentication and Authorization
GitLab integrates with the following external authentication and authorization providers.
LDAP Includes Active Directory, Apple Open Directory, Open LDAP, and 389 Server
OmniAuth Sign in via Twitter, GitHub, GitLab.com, Google, Bitbucket, Facebook, Shibboleth, Crowd, Azure, Authentiq ID, and JWT
CAS Configure GitLab to sign in using CAS
SAML Configure GitLab as a SAML 2.0 Service Provider
Okta Configure GitLab to sign in using Okta
Authentiq: Enable the Authentiq OmniAuth provider for passwordless authentication