Add Prevent Sharing Groups Column to Namespace Settings Table
What does this MR do?
Add prevent_sharing_groups_outside_hierarchy
column to the namespace_settings
table.
When true
, groups can be shared only with other groups that lie within the group hierarchy.
The proof of concept for this issue shows how this fits into the overall picture with the rest of the code to implement the feature: !62623 (closed). In the proof of concept, this column was called share_within_hierarchy_lock
.
Issue: #217623 (closed)
Migration Output
$ bin/rails db:migrate
== 20210527185542 AddPreventSharingGroupsOutsideHierarchyToNamespaceSettings: migrating
-- add_column(:namespace_settings, :prevent_sharing_groups_outside_hierarchy, :boolean, {:null=>false, :default=>false})
-> 0.0022s
== 20210527185542 AddPreventSharingGroupsOutsideHierarchyToNamespaceSettings: migrated (0.0087s)
$ bin/rails dbconsole
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d namespace_settings
Table "public.namespace_settings"
Column | Type | Collation | Nullable | Default
------------------------------------------+--------------------------+-----------+----------+---------
created_at | timestamp with time zone | | not null |
updated_at | timestamp with time zone | | not null |
namespace_id | integer | | not null |
prevent_forking_outside_group | boolean | | not null | false
allow_mfa_for_subgroups | boolean | | not null | true
default_branch_name | text | | |
repository_read_only | boolean | | not null | false
delayed_project_removal | boolean | | |
resource_access_token_creation_allowed | boolean | | not null | true
lock_delayed_project_removal | boolean | | not null | false
prevent_sharing_groups_outside_hierarchy | boolean | | not null | false
Indexes:
"namespace_settings_pkey" PRIMARY KEY, btree (namespace_id)
Check constraints:
"check_0ba93c78c7" CHECK (char_length(default_branch_name) <= 255)
Foreign-key constraints:
"fk_rails_3896d4fae5" FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE
gitlabhq_development=# \q
$ bin/rails db:rollback
== 20210527185542 AddPreventSharingGroupsOutsideHierarchyToNamespaceSettings: reverting
-- remove_column(:namespace_settings, :prevent_sharing_groups_outside_hierarchy)
-> 0.0014s
== 20210527185542 AddPreventSharingGroupsOutsideHierarchyToNamespaceSettings: reverted (0.0084s)
$ bin/rails dbconsole
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d namespace_settings
Table "public.namespace_settings"
Column | Type | Collation | Nullable | Default
----------------------------------------+--------------------------+-----------+----------+---------
created_at | timestamp with time zone | | not null |
updated_at | timestamp with time zone | | not null |
namespace_id | integer | | not null |
prevent_forking_outside_group | boolean | | not null | false
allow_mfa_for_subgroups | boolean | | not null | true
default_branch_name | text | | |
repository_read_only | boolean | | not null | false
delayed_project_removal | boolean | | |
resource_access_token_creation_allowed | boolean | | not null | true
lock_delayed_project_removal | boolean | | not null | false
Indexes:
"namespace_settings_pkey" PRIMARY KEY, btree (namespace_id)
Check constraints:
"check_0ba93c78c7" CHECK (char_length(default_branch_name) <= 255)
Foreign-key constraints:
"fk_rails_3896d4fae5" FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE
gitlabhq_development=# \q
$
Does this MR meet the acceptance criteria?
Conformity
-
I have included a changelog entry, or it's not needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Security
Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.
-
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
Edited by Jason Goodman