Skip to content

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

Availability and Testing

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

Merge request reports