LDAP group sync never completes when subgroup gives lower permission to a user
Summary
Consider the following scenario:
- group
parent_groupwith subgroupchild_group -
parent_groupgives a high level of permission (e.g. Maintainer) toldap_group_1 -
child_groupgives a lower level of permission (e.g. Guest) toldap_group_2
If a user is member of both ldap_group_1 and ldap_group_2, then LDAP sync will never complete for child_group.
In the child group members page, the group is forever in state "syncing..."
Steps to reproduce
- create a group
parent_group, grantMaintainerpermission toldap_group_1 - create a subgroup
child_groupinsideparent_group, grantGuestpermission toldap_group_2 - add a user to both
ldap_group_1andldap_group_2 - make sure LDAP sync completes for
parent_group - from the
child_groupmembers page, clickSync now
Example Project
N/A
What is the current bug behavior?
LDAP sync never completes for child group. The sync state will be forever Syncing...
What is the expected correct behavior?
LDAP sync completes and user member of both LDAP group gets the highest permission (i.e. Maintainer)
Relevant logs and/or screenshots
In the rails console we can see that there are errors in this case because of inherited membership: (applying logic from https://gitlab.com/gitlab-org/gitlab-ee/blob/master/ee/lib/ee/gitlab/auth/ldap/sync/group.rb)
> g=Group.find_by_full_path("parent_group/child_group")
> g.start_ldap_sync
> EE::Gitlab::Auth::LDAP::Sync::Proxy.open(::Gitlab::Auth::LDAP::Config.providers.first) {|proxy| EE::Gitlab::Auth::LDAP::Sync::Group.new(g, proxy).update_permissions}
> g.finish_ldap_sync
=> false # THIS IS THE ISSUE, SYNC CANNOT FINISH!
> g.members.first.errors
=> #<ActiveModel::Errors:0x00007f1344524b90 @base=#<GroupMember id: 1042736, access_level: 10, source_id: 16566, source_type: "Namespace", user_id: 6630, notification_level: 3, type: "GroupMember", created_at: "2019-03-01 10:00:43", updated_at: "2019-03-01 10:00:43", created_by_id: nil, invite_email: nil, invite_token: nil, invite_accepted_at: nil, requested_at: nil, expires_at: nil, ldap: true, override: false>, @messages={:access_level=>["should be higher than Guest inherited membership from group XXXXX"]}, @details={:access_level=>[{:error=>"should be higher than Guest inherited membership from group XXXX"}]}>
Output of checks
(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Proxy: no 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.3 Go Version: unknownGitLab information Version: 11.6.9-ee Revision: d6fc7c7 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql DB Version: 9.6.2 URL: https://gitlab.xxxxx HTTP Clone URL: https://gitlab.xxxxx/some-group/some-project.git SSH Clone URL: ssh://git@gitlab.xxxxx:7999/some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: yes Using Omniauth: yes Omniauth Providers: saml, kerberos_spnego
GitLab Shell Version: 8.4.3 Repository storage paths: xxxxx Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Possible fixes
Possibly the LDAP sync should check for existing inherited membership for the same user?