Login to registry impossible, if user exists on internal auth database
Summary
When user try to login on docker registry, if user exists both on internal directory and LDAP, if user locked on internal directory, API returns 401.
LDAP also selected on user interface by default.
Interaction with git repository over SSH works fine, over HTTP(S) - returns same error.
Steps to reproduce
- Create user on Gitlab interface
- Block it.
- With LDAP auth backend and user with same login try to authenticate
What is the current bug behavior?
Backend check username first on users table and return 401 if found.
On log file registred non-informative record
Filter chain halted as :authenticate_project_or_user rendered or redirected
Completed 401 Unauthorized in 8ms (Views: 0.2ms | ActiveRecord: 1.5ms)
What is the expected correct behavior?
Backend check username on users table and identities, 401 error returns only when user locked on both.
Or write to log file reason why access denied.
Relevant logs and/or screenshots
Part of log files
==> /var/log/gitlab/gitlab-rails/production.log <== Started GET "/jwt/auth?account=only-ldap-user&client_id=docker&offline_token=[FILTERED]&service=container_registry" for 127.0.0.1 at 2019-04-09 11:24:48 +0300 Processing by Gitlab::RequestForgeryProtection::Controller#index as HTML Parameters: {"account"=>"only-ldap-user", "client_id"=>"docker", "offline_token"=>"[FILTERED]", "service"=>"container_registry"} Completed 200 OK in 0ms Processing by Gitlab::RequestForgeryProtection::Controller#index as HTML Parameters: {"account"=>"only-ldap-user", "client_id"=>"docker", "offline_token"=>"[FILTERED]", "service"=>"container_registry"} Completed 200 OK in 0ms Processing by JwtController#auth as HTML Parameters: {"account"=>"only-ldap-user", "client_id"=>"docker", "offline_token"=>"[FILTERED]", "service"=>"container_registry"} User Load (2.1ms) SELECT "users".* FROM "users" WHERE (LOWER("users"."username") = LOWER('only-ldap-user')) LIMIT 1 PersonalAccessToken Load (0.8ms) SELECT "personal_access_tokens".* FROM "personal_access_tokens" WHERE (revoked = false AND (expires_at >= NOW() OR expires_at IS NULL)) AND "personal_access_tokens"."token_digest" = 'TOKEN_DIGEST' LIMIT 1 DeployToken Load (0.4ms) SELECT "deploy_tokens".* FROM "deploy_tokens" WHERE (revoked = false AND expires_at >= NOW()) AND "deploy_tokens"."token" = 'PASSWORD' LIMIT 1 CACHE (0.0ms) SELECT "users".* FROM "users" WHERE (LOWER("users"."username") = LOWER('only-ldap-user')) LIMIT 1 [["LIMIT", 1]] Identity Load (0.4ms) SELECT "identities".* FROM "identities" WHERE "identities"."user_id" = 228 Identity Load (4.9ms) SELECT "identities".* FROM "identities" WHERE (LOWER("identities"."extern_uid") = LOWER('cn=only-ldap-user,ou=users,ou=it,dc=example,dc=com')) AND "identities"."provider" = 'ldapmain' LIMIT 1 User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 228 LIMIT 1 U2fRegistration Exists (17.4ms) SELECT 1 AS one FROM "u2f_registrations" WHERE "u2f_registrations"."user_id" = 228 LIMIT 1 Completed 200 OK in 755ms (Views: 0.2ms | ActiveRecord: 39.2ms)==> /var/log/gitlab/gitlab-rails/production.log <== Started GET "/jwt/auth?account=internal-blocked&client_id=docker&offline_token=[FILTERED]&service=container_registry" for 127.0.0.1 at 2019-04-09 11:26:05 +0300 Processing by Gitlab::RequestForgeryProtection::Controller#index as HTML Parameters: {"account"=>"internal-blocked", "client_id"=>"docker", "offline_token"=>"[FILTERED]", "service"=>"container_registry"} Completed 200 OK in 0ms (ActiveRecord: 0.0ms) Processing by Gitlab::RequestForgeryProtection::Controller#index as HTML Parameters: {"account"=>"internal-blocked", "client_id"=>"docker", "offline_token"=>"[FILTERED]", "service"=>"container_registry"} Completed 200 OK in 0ms (ActiveRecord: 0.0ms) Processing by JwtController#auth as HTML Parameters: {"account"=>"internal-blocked", "client_id"=>"docker", "offline_token"=>"[FILTERED]", "service"=>"container_registry"} User Load (0.9ms) SELECT "users".* FROM "users" WHERE (LOWER("users"."username") = LOWER('internal-blocked')) LIMIT 1 PersonalAccessToken Load (0.3ms) SELECT "personal_access_tokens".* FROM "personal_access_tokens" WHERE (revoked = false AND (expires_at >= NOW() OR expires_at IS NULL)) AND "personal_access_tokens"."token_digest" = 'TOKEN_DIGEST' LIMIT 1 DeployToken Load (0.2ms) SELECT "deploy_tokens".* FROM "deploy_tokens" WHERE (revoked = false AND expires_at >= NOW()) AND "deploy_tokens"."token" = 'PASSWORD' LIMIT 1 CACHE (0.0ms) SELECT "users".* FROM "users" WHERE (LOWER("users"."username") = LOWER('internal-blocked')) LIMIT 1 [["LIMIT", 1]] Filter chain halted as :authenticate_project_or_user rendered or redirected Completed 401 Unauthorized in 8ms (Views: 0.2ms | ActiveRecord: 1.5ms)
Results of GitLab environment info
Expand for output related to the GitLab environment info
System information System: Current User: git Using RVM: no Ruby Version: 2.5.3p105 Gem Version: 2.7.6 Bundler Version:1.16.6 Rake Version: 12.3.2 Redis Version: 3.2.12 Git Version: 2.18.1 Sidekiq Version:5.2.5 Go Version: unknown
GitLab information Version: 11.9.6 Revision: 14bac95 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: https://example.com HTTP Clone URL: https://example.com/some-group/some-project.git SSH Clone URL: git@example.com:some-group/some-project.git Using LDAP: yes Using Omniauth: yes Omniauth Providers:
GitLab Shell Version: 8.7.1 Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 8.7.1 ? ... OK (8.7.1) 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 Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) .............. Checking LDAP ... Finished
Checking GitLab App ...
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? ... yes 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: ... .............. Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.5.3) Git version >= 2.18.0 ? ... yes (2.18.1) Git user has default SSH configuration? ... yes Active users: ... 88
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
Check user on all auth backends before return error or log human readable reason why error returned.