Blocked LDAP user with 2FA enabled throws 500 on login
Summary
When an LDAP user blocked from the GitLab admin has 2FA enabled and logs in, a 500 is thrown.
Steps to reproduce
- Block a user with 2FA enabled
- Have blocked user log in
- 500 error is thrown
Relevant logs and/or screenshots
/var/log/gitlab/unicorn/unicorn_stderr.log
INFO -- omniauth: (ldapmain) Callback phase initiated.
E, [2018-07-02T15:29:02.988075 #54119] ERROR -- omniauth: (ldapmain) Authentication failure! ldap_error: ActionView::Template::Error, undefined method `each_with_index' for nil:NilClass
I, [2018-07-02T15:32:52.678973 #54116] INFO -- omniauth: (ldapmain) Callback phase initiated.
production.log
Completed 500 Internal Server Error in 29ms (ActiveRecord: 1.0ms | Elasticsearch: 0.0ms)
ActionView::Template::Error (undefined method `each_with_index' for nil:NilClass):
5: - if kerberos_enabled?
6: %li{ class: (:active unless crowd_enabled? || ldap_enabled?) }
7: = link_to "Kerberos", "#kerberos", 'data-toggle' => 'tab'
8: - @ldap_servers.each_with_index do |server, i|
9: %li{ class: active_when(i.zero? && !crowd_enabled?) }
10: = link_to server['label'], "##{server['provider_name']}", 'data-toggle' => 'tab'
11: - if password_authentication_enabled_for_web?
app/views/devise/shared/_tabs_ldap.html.haml:8:in `_app_views_devise_shared__tabs_ldap_html_haml__176275396236070497_70039653605300'
app/views/devise/sessions/new.html.haml:5:in `_app_views_devise_sessions_new_html_haml___4435247945239310988_70039650417540'
app/controllers/concerns/authenticates_with_two_factor.rb:38:in `locked_user_redirect'
app/controllers/concerns/authenticates_with_two_factor.rb:43:in `authenticate_with_two_factor'
lib/gitlab/middleware/multipart.rb:95:in `call'
lib/gitlab/request_profiler/middleware.rb:14:in `call'
ee/lib/gitlab/jira/middleware.rb:15:in `call'
lib/gitlab/middleware/go.rb:17:in `call'
lib/gitlab/etag_caching/middleware.rb:11:in `call'
lib/gitlab/middleware/read_only/controller.rb:28:in `call'
lib/gitlab/middleware/read_only.rb:16:in `call'
lib/gitlab/request_context.rb:18:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:27:in `call'
lib/gitlab/middleware/release_env.rb:10:in `call'
Possible fixes
Possibly fixed by https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20076/diffs
Customer ticket -> https://gitlab.zendesk.com/agent/tickets/99350
GitLab Version 10.8.4-ee
Edited by Aric Buerer