Commit 089605fe6b9850ff87e1b1535d084b73e305d627
1 parent
2c191ab0
Exists in
master
and in
4 other branches
Allow the ldap logins with email or username
Change-Id: I73b4aa4c46afd56ae02fb24abcd673c0724547e4
Showing
2 changed files
with
9 additions
and
1 deletions
Show diff stats
config/gitlab.yml.example
| ... | ... | @@ -97,6 +97,7 @@ production: &base |
| 97 | 97 | method: 'ssl' # "ssl" or "plain" |
| 98 | 98 | bind_dn: '_the_full_dn_of_the_user_you_will_bind_with' |
| 99 | 99 | password: '_the_password_of_the_bind_user' |
| 100 | + allow_username_or_email_login: true | |
| 100 | 101 | |
| 101 | 102 | ## OmniAuth settings |
| 102 | 103 | omniauth: | ... | ... |
config/initializers/devise.rb
| ... | ... | @@ -206,6 +206,12 @@ Devise.setup do |config| |
| 206 | 206 | # end |
| 207 | 207 | |
| 208 | 208 | if Gitlab.config.ldap.enabled |
| 209 | + if Gitlab.config.ldap.allow_username_or_email_login | |
| 210 | + email_stripping_proc = Proc.new {|name| name.gsub(/@.*$/,'')} | |
| 211 | + else | |
| 212 | + email_stripping_proc = lambda {|n|n} | |
| 213 | + | |
| 214 | + end | |
| 209 | 215 | config.omniauth :ldap, |
| 210 | 216 | host: Gitlab.config.ldap['host'], |
| 211 | 217 | base: Gitlab.config.ldap['base'], |
| ... | ... | @@ -213,7 +219,8 @@ Devise.setup do |config| |
| 213 | 219 | port: Gitlab.config.ldap['port'], |
| 214 | 220 | method: Gitlab.config.ldap['method'], |
| 215 | 221 | bind_dn: Gitlab.config.ldap['bind_dn'], |
| 216 | - password: Gitlab.config.ldap['password'] | |
| 222 | + password: Gitlab.config.ldap['password'], | |
| 223 | + name_proc: email_stripping_proc | |
| 217 | 224 | end |
| 218 | 225 | |
| 219 | 226 | Gitlab.config.omniauth.providers.each do |provider| | ... | ... |