diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-02-27 16:16:39 -0600 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2017-02-28 14:18:20 +0200 |
commit | 05f331f3ce17ec15377209bf4980b4c91954aa59 (patch) | |
tree | 4a589bead160d9777e355f877d872e1cc23c29a7 /app | |
parent | 71fbbc9da428268411c5a3cef319f7537b63d199 (diff) | |
download | gitlab-ce-05f331f3ce17ec15377209bf4980b4c91954aa59.tar.gz |
Fix access to projects shared with a nested groupdm-nested-group-shared-projects
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | app/services/users/refresh_authorized_projects_service.rb | 16 |
2 files changed, 15 insertions, 3 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 40264401b53..6fb5ac4a4ef 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -474,7 +474,7 @@ class User < ActiveRecord::Base Group.member_descendants(id) end - def nested_projects + def nested_groups_projects Project.joins(:namespace).where('namespaces.parent_id IS NOT NULL'). member_descendants(id) end diff --git a/app/services/users/refresh_authorized_projects_service.rb b/app/services/users/refresh_authorized_projects_service.rb index fad741531ea..d9370bbb598 100644 --- a/app/services/users/refresh_authorized_projects_service.rb +++ b/app/services/users/refresh_authorized_projects_service.rb @@ -115,11 +115,23 @@ module Users # Returns a union query of projects that the user is authorized to access def project_authorizations_union relations = [ + # Personal projects user.personal_projects.select("#{user.id} AS user_id, projects.id AS project_id, #{Gitlab::Access::MASTER} AS access_level"), - user.groups_projects.select_for_project_authorization, + + # Projects the user is a member of user.projects.select_for_project_authorization, + + # Projects of groups the user is a member of + user.groups_projects.select_for_project_authorization, + + # Projects of subgroups of groups the user is a member of + user.nested_groups_projects.select_for_project_authorization, + + # Projects shared with groups the user is a member of user.groups.joins(:shared_projects).select_for_project_authorization, - user.nested_projects.select_for_project_authorization + + # Projects shared with subgroups of groups the user is a member of + user.nested_groups.joins(:shared_projects).select_for_project_authorization ] Gitlab::SQL::Union.new(relations) |