提交 da07665b 编写于 作者: D Dmitriy Zaporozhets

Merge pull request #4289 from karlhungus/feature-ldap-signin-with-email-or-username

Allow the ldap logins with email or username
......@@ -97,6 +97,7 @@ production: &base
method: 'ssl' # "ssl" or "plain"
bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
password: '_the_password_of_the_bind_user'
allow_username_or_email_login: true
## OmniAuth settings
omniauth:
......
......@@ -37,6 +37,8 @@ end
# Default settings
Settings['ldap'] ||= Settingslogic.new({})
Settings.ldap['enabled'] = false if Settings.ldap['enabled'].nil?
Settings.ldap['allow_username_or_email_login'] = false if Settings.ldap['allow_username_or_email_login'].nil?
Settings['omniauth'] ||= Settingslogic.new({})
Settings.omniauth['enabled'] = false if Settings.omniauth['enabled'].nil?
......
......@@ -206,6 +206,12 @@ Devise.setup do |config|
# end
if Gitlab.config.ldap.enabled
if Gitlab.config.ldap.allow_username_or_email_login
email_stripping_proc = ->(name) {name.gsub(/@.*$/,'')}
else
email_stripping_proc = ->(name) {name}
end
config.omniauth :ldap,
host: Gitlab.config.ldap['host'],
base: Gitlab.config.ldap['base'],
......@@ -213,7 +219,8 @@ Devise.setup do |config|
port: Gitlab.config.ldap['port'],
method: Gitlab.config.ldap['method'],
bind_dn: Gitlab.config.ldap['bind_dn'],
password: Gitlab.config.ldap['password']
password: Gitlab.config.ldap['password'],
name_proc: email_stripping_proc
end
Gitlab.config.omniauth.providers.each do |provider|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册