Resolve "Shared group not visible"
What does this MR do?
Include shared with groups in user's list of authorized groups.
Authorized groups are all groups where user is defined as a direct member. This is in contrast to an indirect membership through inheritance.
The system has previously incorrectly or incompletely ignored shared group memberships. This commit will transfer direct membership from one group in to another group when shared.
Furthermore, this MR fixes an incorrect assumption made in !32008 (diffs). With this MR, members of group A shared in to group B will become direct authorized members of Group B.
This functionality is hidden behind a feature flag called shared_group_membership_auth
to limit surprises by second order effects.
User#authorized_groups with FF enabled
SELECT
"namespaces".*
FROM
(
(WITH "direct_groups" AS
(
SELECT
"namespaces".*
FROM
(
(
SELECT
"namespaces".*
FROM
"namespaces"
INNER JOIN
"members"
ON "namespaces"."id" = "members"."source_id"
WHERE
"members"."type" = 'GroupMember'
AND "members"."source_type" = 'Namespace'
AND "namespaces"."type" = 'Group'
AND "members"."user_id" = 4092171
AND "members"."requested_at" IS NULL
AND
(
access_level >= 10
)
)
UNION
(
SELECT
namespaces.*
FROM
"projects"
INNER JOIN
"project_authorizations"
ON "projects"."id" = "project_authorizations"."project_id"
INNER JOIN
"namespaces"
ON "namespaces"."id" = "projects"."namespace_id"
WHERE
"project_authorizations"."user_id" = 4092171)
)
namespaces
WHERE
"namespaces"."type" = 'Group'
)
SELECT
"namespaces".*
FROM
(
(
SELECT
"namespaces".*
FROM
"direct_groups" "namespaces"
WHERE
"namespaces"."type" = 'Group')
UNION
(
SELECT
"namespaces".*
FROM
"namespaces"
INNER JOIN
"group_group_links"
ON "group_group_links"."shared_with_group_id" = "namespaces"."id"
WHERE
"namespaces"."type" = 'Group'
AND "group_group_links"."shared_group_id" = NULL)
)
namespaces
WHERE
"namespaces"."type" = 'Group')
)
namespaces
WHERE
"namespaces"."type" = 'Group'
Time: 10.495 s
- planning: 4.054 ms
- execution: 10.491 s
- I/O read: 10.193 s
- I/O write: 0.000 ms
Shared buffers:
- hits: 22549 (~176.20 MiB) from the buffer pool
- reads: 8102 (~63.30 MiB) from the OS file cache, including disk I/O
- dirtied: 76 (~608.00 KiB)
- writes: 0
Without feature flag enabled:
With feature flag enabled:
Screenshots (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Related to #224771 (closed)