2019-09-04 21:01:54 +05:30
---
2020-10-24 23:57:45 +05:30
stage: Create
group: Source Code
2021-02-22 17:27:13 +05:30
info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments"
2019-09-04 21:01:54 +05:30
type: reference
---
2021-10-27 15:23:28 +05:30
# Control access and visibility **(FREE SELF)**
2016-08-24 12:49:21 +05:30
2021-10-27 15:23:28 +05:30
GitLab enables users with the [Administrator role ](../../permissions.md ) to enforce
specific controls on branches, projects, snippets, groups, and more.
2019-09-04 21:01:54 +05:30
To access the visibility and access control options:
2021-09-04 01:27:46 +05:30
1. Sign in to GitLab as a user with [Administrator role ](../../permissions.md ).
2021-11-11 11:23:49 +05:30
1. On the top bar, select **Menu > Admin** .
1. On the left sidebar, select **Settings > General** .
2019-09-04 21:01:54 +05:30
1. Expand the **Visibility and access controls** section.
2021-10-27 15:23:28 +05:30
## Protect default branches
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
With this option, you can define [branch protections ](../../project/protected_branches.md )
to apply to every repository's [default branch ](../../project/repository/branches/default.md ).
2021-11-18 22:05:49 +05:30
These protections specify the user roles with permission to push to default branches.
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
This setting applies only to each repository's default branch. To protect other branches,
you must configure [branch protection in the repository ](../../project/protected_branches.md ),
or configure [branch protection for groups ](../../group/index.md#change-the-default-branch-protection-of-a-group ).
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
To change the default branch protection for the entire instance:
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
1. Sign in to GitLab as a user with [Administrator role ](../../permissions.md ).
2021-11-11 11:23:49 +05:30
1. On the top bar, select **Menu > Admin** .
1. On the left sidebar, select **Settings > General** .
2021-10-27 15:23:28 +05:30
1. Expand the **Visibility and access controls** section.
1. Select a **Default branch protection** :
2021-11-18 22:05:49 +05:30
- **Not protected** - Both developers and maintainers can push new commits
and force push.
2021-10-27 15:23:28 +05:30
- **Protected against pushes** - Developers cannot push new commits, but are
allowed to accept merge requests to the branch. Maintainers can push to the branch.
- **Partially protected** - Both developers and maintainers can push new commits,
2021-11-18 22:05:49 +05:30
but cannot force push.
2021-10-27 15:23:28 +05:30
- **Fully protected** - Developers cannot push new commits, but maintainers can.
2021-11-18 22:05:49 +05:30
No one can force push.
2021-10-27 15:23:28 +05:30
1. To allow group owners to override the instance's default branch protection, select
[**Allow owners to manage default branch protection per group** ](#prevent-overrides-of-default-branch-protection ).
1. Select **Save changes** .
2020-04-08 14:13:33 +05:30
2021-10-27 15:23:28 +05:30
### Prevent overrides of default branch protection **(PREMIUM SELF)**
2020-05-24 23:13:21 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/211944) in GitLab 13.0.
2021-10-27 15:23:28 +05:30
Instance-level protections for [default branch ](../../project/repository/branches/default.md )
can be overridden on a per-group basis by the group's owner. In
[GitLab Premium or higher ](https://about.gitlab.com/pricing/ ), GitLab administrators can
disable this privilege for group owners, enforcing the instance-level protection rule:
2020-05-24 23:13:21 +05:30
2021-10-27 15:23:28 +05:30
1. Sign in to GitLab as a user with [Administrator role ](../../permissions.md ).
2021-11-11 11:23:49 +05:30
1. On the top bar, select **Menu > Admin** .
1. On the left sidebar, select **Settings > General** .
2021-10-27 15:23:28 +05:30
1. Expand the **Visibility and access controls** section.
1. Deselect the **Allow owners to manage default branch protection per group** checkbox.
1. Select **Save changes** .
2020-05-24 23:13:21 +05:30
2021-02-22 17:27:13 +05:30
NOTE:
2020-05-24 23:13:21 +05:30
GitLab administrators can still update the default branch protection of a group.
2021-10-27 15:23:28 +05:30
## Define which roles can create projects
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
Instance-level protections for project creation define which roles can
2021-12-11 22:18:48 +05:30
[add projects to a group ](../../group/index.md#specify-who-can-add-projects-to-a-group )
2021-10-27 15:23:28 +05:30
on the instance. To alter which roles have permission to create projects:
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
1. Sign in to GitLab as a user with [Administrator role ](../../permissions.md ).
2021-11-11 11:23:49 +05:30
1. On the top bar, select **Menu > Admin** .
1. On the left sidebar, select **Settings > General** .
2021-10-27 15:23:28 +05:30
1. Expand the **Visibility and access controls** section.
1. For **Default project creation protection** , select the desired roles:
- No one.
- Maintainers.
- Developers and Maintainers.
1. Select **Save changes** .
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
## Restrict project deletion to Administrators **(PREMIUM SELF)**
Anyone with the **Owner** role, either at the project or group level, can
delete a project. To allow only users with the Administrator role to delete projects:
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
1. Sign in to GitLab as a user with [Administrator role ](../../permissions.md ).
2021-11-11 11:23:49 +05:30
1. On the top bar, select **Menu > Admin** .
1. On the left sidebar, select **Settings > General** .
2021-10-27 15:23:28 +05:30
1. Expand the **Visibility and access controls** section.
1. Scroll to **Default project deletion protection** , and select **Only admins can delete project** .
1. Select **Save changes** .
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
## Default delayed project deletion **(PREMIUM SELF)**
2019-12-21 20:55:43 +05:30
2021-11-11 11:23:49 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/255449) in GitLab 14.2 for groups created after August 12, 2021.
2019-12-21 20:55:43 +05:30
2021-11-11 11:23:49 +05:30
Projects in a group (but not a personal namespace) can be deleted after a delayed period.
You can [configure it in group settings ](../../group/index.md#enable-delayed-project-removal ).
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
To enable delayed project deletion by default in new groups:
1. Check the **Default delayed project deletion** checkbox.
2021-11-11 11:23:49 +05:30
1. Select **Save changes** .
2019-12-21 20:55:43 +05:30
2021-03-11 19:13:27 +05:30
## Default deletion delay **(PREMIUM SELF)**
2020-01-01 13:55:28 +05:30
2020-06-23 00:09:42 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/32935) in GitLab 12.6.
2020-01-01 13:55:28 +05:30
2021-03-11 19:13:27 +05:30
By default, a project marked for deletion is permanently removed with immediate effect.
By default, a group marked for deletion is permanently removed after seven days.
2020-07-28 23:09:34 +05:30
2021-02-22 17:27:13 +05:30
WARNING:
2020-07-28 23:09:34 +05:30
The default behavior of [Delayed Project deletion ](https://gitlab.com/gitlab-org/gitlab/-/issues/32935 ) in GitLab 12.6 was changed to
[Immediate deletion ](https://gitlab.com/gitlab-org/gitlab/-/issues/220382 ) in GitLab 13.2.
2021-03-11 19:13:27 +05:30
Projects in a group (but not a personal namespace) can be deleted after a delayed period, by
2021-04-17 20:07:23 +05:30
[configuring in Group Settings ](../../group/index.md#enable-delayed-project-removal ).
2021-03-11 19:13:27 +05:30
The default period is seven days, and can be changed. Setting this period to `0` enables immediate removal
2020-03-13 15:44:24 +05:30
of projects or groups.
2020-01-01 13:55:28 +05:30
To change this period:
1. Select the desired option.
1. Click **Save changes** .
2021-10-27 15:23:28 +05:30
### Override defaults and delete immediately
2020-05-24 23:13:21 +05:30
Alternatively, projects that are marked for removal can be deleted immediately. To do so:
2020-11-24 15:15:51 +05:30
1. [Restore the project ](../../project/settings/#restore-a-project ).
2021-09-30 23:02:18 +05:30
1. Delete the project as described in the
[Administering Projects page ](../../admin_area/#administering-projects ).
2020-05-24 23:13:21 +05:30
2021-10-27 15:23:28 +05:30
## Configure project visibility defaults
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
To set the default [visibility levels for new projects ](../../../public_access/public_access.md ):
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
1. Sign in to GitLab as a user with [Administrator role ](../../permissions.md ).
2021-11-11 11:23:49 +05:30
1. On the top bar, select **Menu > Admin** .
1. On the left sidebar, select **Settings > General** .
2021-10-27 15:23:28 +05:30
1. Expand the **Visibility and access controls** section.
1. Select the desired default project visibility:
- **Private** - Project access must be granted explicitly to each user. If this
project is part of a group, access will be granted to members of the group.
- **Internal** - The project can be accessed by any logged in user except external users.
- **Public** - The project can be accessed without any authentication.
1. Select **Save changes** .
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
## Configure snippet visibility defaults
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
To set the default visibility levels for new [snippets ](../../snippets.md ):
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
1. Sign in to GitLab as a user with [Administrator role ](../../permissions.md ).
2021-11-11 11:23:49 +05:30
1. On the top bar, select **Menu > Admin** .
1. On the left sidebar, select **Settings > General** .
2021-10-27 15:23:28 +05:30
1. Expand the **Visibility and access controls** section.
2019-12-21 20:55:43 +05:30
1. Select the desired default snippet visibility.
2021-10-27 15:23:28 +05:30
1. Select **Save changes** .
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
For more details on snippet visibility, read
2021-09-30 23:02:18 +05:30
[Project visibility ](../../../public_access/public_access.md ).
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
## Configure group visibility defaults
2019-12-21 20:55:43 +05:30
To set the default visibility levels for new groups:
2021-10-27 15:23:28 +05:30
1. Sign in to GitLab as a user with [Administrator role ](../../permissions.md ).
2021-11-11 11:23:49 +05:30
1. On the top bar, select **Menu > Admin** .
1. On the left sidebar, select **Settings > General** .
2021-10-27 15:23:28 +05:30
1. Expand the **Visibility and access controls** section.
1. Select the desired default group visibility:
- **Private** - The group and its projects can only be viewed by members.
- **Internal** - The group and any internal projects can be viewed by any logged in user except external users.
- **Public** - The group and any public projects can be viewed without any authentication.
1. Select **Save changes** .
2019-12-21 20:55:43 +05:30
2021-09-30 23:02:18 +05:30
For more details on group visibility, see
[Group visibility ](../../group/index.md#group-visibility ).
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
## Restrict visibility levels
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
To restrict visibility levels for projects, snippets, and selected pages:
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
1. Sign in to GitLab as a user with [Administrator role ](../../permissions.md ).
2021-11-11 11:23:49 +05:30
1. On the top bar, select **Menu > Admin** .
1. On the left sidebar, select **Settings > General** .
2021-10-27 15:23:28 +05:30
1. Expand the **Visibility and access controls** section.
1. In the **Restricted visibility levels** section, select the desired visibility levels to restrict.
2021-03-11 19:13:27 +05:30
1. Select **Save changes** .
2019-12-21 20:55:43 +05:30
2021-09-30 23:02:18 +05:30
For more details on project visibility, see
[Project visibility ](../../../public_access/public_access.md ).
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
## Configure allowed import sources
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
You can specify from which hosting sites users can [import their projects ](../../project/import/index.md ):
2019-02-15 15:39:39 +05:30
2021-10-27 15:23:28 +05:30
1. Sign in to GitLab as a user with [Administrator role ](../../permissions.md ).
2021-11-11 11:23:49 +05:30
1. On the top bar, select **Menu > Admin** .
1. On the left sidebar, select **Settings > General** .
2021-10-27 15:23:28 +05:30
1. Expand the **Visibility and access controls** section.
1. Select each of **Import sources** to allow.
1. Select **Save changes** .
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
## Enable project export
2019-12-21 20:55:43 +05:30
2021-10-27 15:23:28 +05:30
To enable the export of
[projects and their data ](../../../user/project/settings/import_export.md#export-a-project-and-its-data ):
2019-02-15 15:39:39 +05:30
2021-10-27 15:23:28 +05:30
1. Sign in to GitLab as a user with [Administrator role ](../../permissions.md ).
2021-11-11 11:23:49 +05:30
1. On the top bar, select **Menu > Admin** .
1. On the left sidebar, select **Settings > General** .
2021-10-27 15:23:28 +05:30
1. Expand the **Visibility and access controls** section.
1. Select **Project export enabled** .
1. Select **Save changes** .
2016-08-24 12:49:21 +05:30
2021-10-27 15:23:28 +05:30
## Configure enabled Git access protocols
2016-08-24 12:49:21 +05:30
2021-10-27 15:23:28 +05:30
With GitLab access restrictions, you can select the protocols users can use to
communicate with GitLab. Disabling an access protocol does not block port access to the
server itself. The ports used for the protocol, SSH or HTTP(S), are still accessible.
The GitLab restrictions apply at the application level.
2016-08-24 12:49:21 +05:30
2019-12-21 20:55:43 +05:30
To specify the enabled Git access protocols:
2016-08-24 12:49:21 +05:30
2021-10-27 15:23:28 +05:30
1. Sign in to GitLab as a user with [Administrator role ](../../permissions.md ).
2021-11-11 11:23:49 +05:30
1. On the top bar, select **Menu > Admin** .
1. On the left sidebar, select **Settings > General** .
2021-10-27 15:23:28 +05:30
1. Expand the **Visibility and access controls** section.
1. Select the desired Git access protocols:
2019-12-21 20:55:43 +05:30
- Both SSH and HTTP(S)
- Only SSH
- Only HTTP(S)
2021-10-27 15:23:28 +05:30
1. Select **Save changes** .
2016-08-24 12:49:21 +05:30
2019-12-21 20:55:43 +05:30
When both SSH and HTTP(S) are enabled, users can choose either protocol.
2021-10-27 15:23:28 +05:30
If only one protocol is enabled:
2016-08-24 12:49:21 +05:30
2021-03-11 19:13:27 +05:30
- The project page shows only the allowed protocol's URL, with no option to
2016-08-24 12:49:21 +05:30
change it.
2021-10-27 15:23:28 +05:30
- GitLab shows a tooltip when you hover over the URL's protocol, if user action
(such as adding a SSH key or setting a password) is required:
2016-08-24 12:49:21 +05:30
2021-10-27 15:23:28 +05:30
![Project URL with SSH only access ](img/restricted_url.png )
2016-08-24 12:49:21 +05:30
2021-10-27 15:23:28 +05:30
GitLab only allows Git actions for the protocols you select.
2016-08-24 12:49:21 +05:30
2021-02-22 17:27:13 +05:30
WARNING:
2021-03-11 19:13:27 +05:30
GitLab versions [10.7 and later ](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/18021 ),
allow the HTTP(S) protocol for Git clone or fetch requests done by GitLab Runner
2021-10-27 15:23:28 +05:30
from CI/CD jobs, even if you select **Only SSH** .
2018-05-09 12:01:36 +05:30
2021-10-27 15:23:28 +05:30
## Customize Git clone URL for HTTP(S)
2019-12-21 20:55:43 +05:30
2020-03-13 15:44:24 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/18422) in GitLab 12.4.
2019-12-21 20:55:43 +05:30
2021-03-11 19:13:27 +05:30
You can customize project Git clone URLs for HTTP(S), which affects the clone
2019-12-21 20:55:43 +05:30
panel:
For example, if:
- Your GitLab instance is at `https://example.com` , then project clone URLs are like
`https://example.com/foo/bar.git` .
- You want clone URLs that look like `https://git.example.com/gitlab/foo/bar.git` instead,
you can set this setting to `https://git.example.com/gitlab/` .
![Custom Git clone URL for HTTP ](img/custom_git_clone_url_for_https_v12_4.png )
To specify a custom Git clone URL for HTTP(S):
1. Enter a root URL for **Custom Git clone URL for HTTP(S)** .
1. Click on **Save changes** .
2021-02-22 17:27:13 +05:30
NOTE:
2019-12-21 20:55:43 +05:30
SSH clone URLs can be customized in `gitlab.rb` by setting `gitlab_rails['gitlab_ssh_host']` and
other related settings.
2021-10-27 15:23:28 +05:30
## Configure defaults for RSA, DSA, ECDSA, ED25519 SSH keys
2019-12-21 20:55:43 +05:30
These options specify the permitted types and lengths for SSH keys.
To specify a restriction for each key type:
1. Select the desired option from the dropdown.
1. Click **Save changes** .
For more details, see [SSH key restrictions ](../../../security/ssh_keys_restrictions.md ).
2016-08-24 12:49:21 +05:30
2021-10-27 15:23:28 +05:30
## Enable project mirroring
2019-07-31 22:56:46 +05:30
2021-03-11 19:13:27 +05:30
This option is enabled by default. By disabling it, both
2021-11-18 22:05:49 +05:30
[pull mirroring ](../../project/repository/mirror/pull.md ) and [push mirroring ](../../project/repository/mirror/push.md ) no longer
2021-03-11 19:13:27 +05:30
work in every repository. They can only be re-enabled by an administrator user on a per-project basis.
2019-07-31 22:56:46 +05:30
![Mirror settings ](img/mirror_settings.png )
2019-09-04 21:01:54 +05:30
<!-- ## Troubleshooting
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
one might have when setting this up, or when something is changed, or on upgrading, it's
important to describe those, too. Think of things that may go wrong and include them here.
This is important to minimize requests for support, and to avoid doc comments with
questions that you know someone might ask.
Each scenario can be a third-level heading, e.g. `### Getting error message X` .
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->