Commit 089605fe authored by Izaak Alpert's avatar Izaak Alpert

Allow the ldap logins with email or username

Change-Id: I73b4aa4c46afd56ae02fb24abcd673c0724547e4
parent 2c191ab0
...@@ -97,6 +97,7 @@ production: &base ...@@ -97,6 +97,7 @@ production: &base
method: 'ssl' # "ssl" or "plain" method: 'ssl' # "ssl" or "plain"
bind_dn: '_the_full_dn_of_the_user_you_will_bind_with' bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
password: '_the_password_of_the_bind_user' password: '_the_password_of_the_bind_user'
allow_username_or_email_login: true
## OmniAuth settings ## OmniAuth settings
omniauth: omniauth:
......
...@@ -206,6 +206,12 @@ Devise.setup do |config| ...@@ -206,6 +206,12 @@ Devise.setup do |config|
# end # end
if Gitlab.config.ldap.enabled if Gitlab.config.ldap.enabled
if Gitlab.config.ldap.allow_username_or_email_login
email_stripping_proc = Proc.new {|name| name.gsub(/@.*$/,'')}
else
email_stripping_proc = lambda {|n|n}
end
config.omniauth :ldap, config.omniauth :ldap,
host: Gitlab.config.ldap['host'], host: Gitlab.config.ldap['host'],
base: Gitlab.config.ldap['base'], base: Gitlab.config.ldap['base'],
...@@ -213,7 +219,8 @@ Devise.setup do |config| ...@@ -213,7 +219,8 @@ Devise.setup do |config|
port: Gitlab.config.ldap['port'], port: Gitlab.config.ldap['port'],
method: Gitlab.config.ldap['method'], method: Gitlab.config.ldap['method'],
bind_dn: Gitlab.config.ldap['bind_dn'], bind_dn: Gitlab.config.ldap['bind_dn'],
password: Gitlab.config.ldap['password'] password: Gitlab.config.ldap['password'],
name_proc: email_stripping_proc
end end
Gitlab.config.omniauth.providers.each do |provider| Gitlab.config.omniauth.providers.each do |provider|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment