NoMethodError (undefined method `uid' for nil:NilClass)
Summary
When authenticating against Active Directory, the login immediately fails with a 500 error.
Steps to reproduce
Enter a valid LDAP user in the login
Example Project=
N/A
What is the current bug behavior?
User immediately sees a 500 error.
What is the expected correct behavior?
Successful login.
Relevant logs and/or screenshots
This is reported in the production.log:
Started POST "/users/auth/ldapwustl_accounts/callback" for 10.28.23.80 at 2018-07-05 10:18:23 -0500
Processing by Ldap::OmniauthCallbacksController#ldapwustl_accounts as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "username"=>"lschweiss", "password"=>"[FILTERED]"}
Completed 500 Internal Server Error in 6ms (ActiveRecord: 0.0ms)
NoMethodError (undefined method `uid' for nil:NilClass):
lib/gitlab/auth/o_auth/auth_hash.rb:13:in `uid'
lib/gitlab/auth/ldap/auth_hash.rb:8:in `uid'
lib/gitlab/auth/ldap/user.rb:31:in `find_by_uid_and_provider'
lib/gitlab/auth/ldap/user.rb:27:in `find_user'
lib/gitlab/auth/o_auth/user.rb:57:in `gl_user'
lib/gitlab/auth/o_auth/user.rb:248:in `clear_user_synced_attributes_metadata'
lib/gitlab/auth/o_auth/user.rb:222:in `update_profile'
lib/gitlab/auth/o_auth/user.rb:17:in `initialize'
app/controllers/omniauth_callbacks_controller.rb:114:in `new'
app/controllers/omniauth_callbacks_controller.rb:114:in `sign_in_user_flow'
app/controllers/ldap/omniauth_callbacks_controller.rb:15:in `ldap'
lib/gitlab/i18n.rb:50:in `with_locale'
lib/gitlab/i18n.rb:56:in `with_user_locale'
app/controllers/application_controller.rb:362:in `set_locale'
lib/gitlab/middleware/multipart.rb:95:in `call'
lib/gitlab/request_profiler/middleware.rb:14:in `call'
lib/gitlab/middleware/go.rb:17:in `call'
lib/gitlab/etag_caching/middleware.rb:11:in `call'
lib/gitlab/middleware/rails_queue_duration.rb:22:in `call'
lib/gitlab/metrics/rack_middleware.rb:15:in `block in call'
lib/gitlab/metrics/transaction.rb:53:in `run'
lib/gitlab/metrics/rack_middleware.rb:15: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'
Output of checks
(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)
Results of GitLab environment info
System information
System:
Current User: git
Using RVM: no
Ruby Version: 2.4.4p296
Gem Version: 2.7.6
Bundler Version:1.16.2
Rake Version: 12.3.1
Redis Version: 3.2.11
Git Version: 2.17.1
Sidekiq Version:5.1.3
Go Version: unknown
GitLab information
Version: 11.0.2
Revision: d9540ee
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: postgresql
URL: https://git.nrg.wustl.edu
HTTP Clone URL: https://git.nrg.wustl.edu/some-group/some-project.git
SSH Clone URL: git@git.nrg.wustl.edu:some-group/some-project.git
Using LDAP: yes
Using Omniauth: no
GitLab Shell
Version: 7.1.4
Repository storage paths:
- default: /data/git/git-data/repositories
Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks
Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
# gitlab-rake gitlab:check SANITIZE=true
Checking GitLab Shell ...
GitLab Shell version >= 7.1.4 ? ... OK (7.1.4)
Repo base directory exists?
default... yes
Repo storage directories are symlinks?
default... no
Repo paths owned by git:root, or 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
Redis available via internal API: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK
gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes
Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Reply by email is disabled in config/gitlab.yml
Checking LDAP ...
Server: ldapwustl_accounts
LDAP authentication... Success
LDAP users with access to your GitLab server (only showing the first 100 results)
DN: cn=west\, ben,ou=non current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: benwest
DN: cn=mahmoudzadeh\, ehsan,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: ehsanm
DN: cn=moore\, charles james,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: moore.c
DN: cn=mckay\, michael f,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: mfmckay
DN: cn=schweiss\, lester h,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: lschweiss
DN: cn=horton\, william h.,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: hortonw
DN: cn=mohammadian foroushani\, hossein,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: hossein
DN: cn=kansagra\, akash pravin,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: kansagra
DN: cn=gonzales\, sergio,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: sergiog
DN: cn=chang\, junil,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: junilc
DN: cn=gezella\, cathy m,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: gezellac
DN: cn=halim\, debbie,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: dhalim
DN: cn=muskopf\, john,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: jmuskopf
DN: cn=moore\, stephen m,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: moore.stephen.m
DN: cn=hileman\, michael,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: mhileman
DN: cn=gurney\, genevieve,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: gkgurney
DN: cn=brown\, timothy brian,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: tbbrown
DN: cn=kelsey\, matthew douglas,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: kelseym
DN: cn=don\, steven,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: steven.don
DN: cn=commean\, paul kevin,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: commeanp
DN: cn=milchenko\, mikhail v,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: mmilchenko
DN: cn=marcus\, daniel scott,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: dmarcus
DN: cn=politte\, david gerard,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: politted
DN: cn=kelley\, aidan matthews,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: aidankelley
DN: cn=tobias\, malcolm,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: mtobias
DN: cn=kaushal\, atul,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: akaushal
DN: cn=wolfsberger\, mary a,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: mwolfsberger
DN: cn=cler\, eileen a,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: clere
DN: cn=hunt\, matthew,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: huntm
DN: cn=hodge\, michael robert,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: hodgem
DN: cn=wallace\, lauren,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: laurenwallace
DN: cn=farrar\, angela marie,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: angelaj
DN: cn=herrick\, james r,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: jrherrick
DN: cn=huang\, xing 3,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: xinghuang
DN: cn=hildebolt\, charles f,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: hildeboltc
DN: cn=lamontagne\, pamela j,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: pjlamontagne
DN: cn=chakrabarty\, satrajit,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: satrajit.chakrabarty
DN: cn=maffitt\, david r,ou=current,ou=people,dc=accounts,dc=ad,dc=wustl,dc=edu sAMAccountName: david.maffitt
Checking LDAP ... Finished
Checking GitLab ...
Git configured correctly? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config up to date? ... yes
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory exists? ... yes
Uploads directory has correct permissions? ... yes
Uploads directory tmp has correct permissions? ... 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.3.5 ? ... yes (2.4.4)
Git version >= 2.9.5 ? ... yes (2.17.1)
Git user has default SSH configuration? ... yes
Active users: ... 1
Checking GitLab ... Finished
Possible fixes
(If you can, link to the line of code that might be responsible for the problem)