上一篇文章介绍了SVN集成OpenLDAP认证,版本控制除了SVN外,Git目前也被越来越多的开发者所喜爱,本文将介绍GitLab如何集成OpenLDAP实现账号认证
GitLab配置
修改配置文件gitlab.yml
ldap: enabled: true servers: main: label: 'LDAP' host: 'ldap.ops-coffee.cn' port: 389 uid: 'uid' method: 'plain' bind_dn: 'uid=authz,ou=Public,dc=ops-coffee,dc=cn' password: 'ImNVZODT884' timeout: 10 active_directory: false allow_username_or_email_login: false block_auto_created_users: false base: 'dc=ops-coffee,dc=cn' user_filter: ''
重启GitLab服务,看到页面已经有LDAP的登录选项了
重要配置参数解释
仔细阅读上一篇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
报错处理
当重启完成后登陆报:Could not authenticate you from Ldapmain because "Invalid credentials"
查日志有如下报错:(LDAP) Error saving user: ["Email is not whitelisted. Email domains valid for registration are: domain.com"]
Email不在白名单??仔细想了一下原因:
GitLab之前为了安全配置了 Restricted domains for sign-ups只允许domain.com邮箱的用户注册
而我OpenLDAP在新建用户的时候邮箱没有填写为空
或许就是这个问题了,登录lam将用户的邮箱字段补上(需符合白名单规则)重新登录便正常了
推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:https://zblog.hqyman.cn/post/11808.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
休息一下~~