Underscore in LDAP Provider 'ID' causes 500 Internal Server Error
Summary
When setting up LDAP authentication, having an underscore in the provider 'ID' (e.g. ldap_directory) causes an internal server error.
Steps to reproduce
Add an _ to the LDAP provider ID, reconfigure, restart and try to login with the LDAP method.
What is the current bug behavior?
When logging in via LDAP you get a screen that reports 500 Internal Server Error
What is the expected correct behavior?
You should be able to login without an issue.
Relevant logs and/or screenshots
Processing by OmniauthCallbacksController#ldapeservices_dir as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"2auWl7VrJqBDUkY/vlZSBg+yRctLI1Qdf5RzNB6rNs4Wz/MfnQBlb3moq7H8IMGE8WryXxwS5EJTbK0VVCjYLw==", "username"=>"mst3k", "password"=>"[FILTERED]"}
Completed 500 Internal Server Error in 18ms (ActiveRecord: 1.5ms)
NoMethodError (undefined method `provider' for nil:NilClass):
lib/gitlab/o_auth/auth_hash.rb:29:in `provider'
lib/gitlab/o_auth/auth_hash.rb:16:in `normalized_uid'
lib/gitlab/o_auth/auth_hash.rb:25:in `uid'
lib/gitlab/ldap/user.rb:37:in `find_by_uid_and_provider'
lib/gitlab/ldap/user.rb:33:in `gl_user'
lib/gitlab/o_auth/user.rb:18:in `persisted?'
lib/gitlab/ldap/user.rb:45:in `update_user_attributes'
lib/gitlab/ldap/user.rb:24:in `initialize'
app/controllers/omniauth_callbacks_controller.rb:25:in `new'
app/controllers/omniauth_callbacks_controller.rb:25:in `ldap'
lib/gitlab/middleware/multipart.rb:93:in `call'
lib/gitlab/request_profiler/middleware.rb:14:in `call'
lib/gitlab/middleware/go.rb:16:in `call'
lib/gitlab/middleware/readonly_geo.rb:30:in `call'
Results of GitLab environment info
System information
System: CentOS 7.3.1611
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 2.3.3p222
Gem Version: 2.6.6
Bundler Version:1.13.7
Rake Version: 10.5.0
Redis Version: 3.2.5
Sidekiq Version:4.2.7
GitLab information
Version: 8.17.2-ee
Revision: 474978d
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: postgresql
DB Version: 9.2.18
URL: https://gitlab-hsz.its.virginia.edu
HTTP Clone URL: https://gitlab-hsz.its.virginia.edu/some-group/some-project.git
SSH Clone URL: git@gitlab-hsz.its.virginia.edu:some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: yes
Using Omniauth: no
GitLab Shell
Version: 4.1.1
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks/
Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
I condensed the LDAP check down to 1 result instead of the 100 it created and sanitized the username it returned.
Checking GitLab Shell ...
GitLab Shell version >= 4.1.1 ? ... OK (4.1.1)
Repo base directory exists?
default... yes
Repo storage directories are symlinks?
default... no
Repo paths owned by git:git?
default... yes
Repo paths access is drwxrws---?
default... yes
hooks directories in repos are links: ... can't check, you have no projects
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK
Send ping to redis server: OK
gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes
Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Reply by email ...
Reply by email is disabled in config/gitlab.yml
Checking Reply by email ... Finished
Checking LDAP ...
Server: ldapeservices
LDAP authentication... Success
LDAP users with access to your GitLab server (only showing the first 100 results)
DN: CN=mst3k,CN=Users,DC=eservices,DC=virginia,DC=edu samaccountname: mst3k
Checking LDAP ... Finished
Checking GitLab ...
Git configured with autocrlf=input? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory setup correctly? ... skipped (no tmp uploads folder yet)
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
projects have namespace: ... can't check, you have no projects
Redis version >= 2.8.0? ... yes
Ruby version >= 2.1.0 ? ... yes (2.3.3)
Your git bin path is "/opt/gitlab/embedded/bin/git"
Git version >= 2.7.3 ? ... yes (2.10.2)
Active users: 2
Checking GitLab ... Finished