doc/user/packages/package_registry/package_protection_rules.md
{{< details >}}
{{< /details >}}
{{< history >}}
packages_protected_packages. Disabled by default. This feature is an experiment.packages_protected_packages removed.packages_protected_packages_conan. Disabled by default. This feature is an experiment.packages_protected_packages_maven. Disabled by default. This feature is an experiment.packages_protected_packages_delete. Disabled by default. This feature is an experiment.packages_protected_packages_maven removed.packages_protected_packages_conan removed.packages_protected_packages_nuget. Disabled by default. This feature is an experiment.packages_protected_packages_helm. Disabled by default. This feature is an experiment.packages_protected_packages_generic. Disabled by default. This feature is an experiment.packages_protected_packages_generic removed.packages_protected_packages_nuget removed.packages_protected_packages_helm removed.{{< /history >}}
By default, any user with the Developer, Maintainer, or Owner role can create, edit, and delete packages. Add a package protection rule to restrict which users can make changes to your packages.
GitLab supports package protection for npm, PyPI, Maven, and Conan packages, but epic 5574 proposes to add additional features and package formats.
When a package is protected, the default behavior enforces these restrictions on the package:
| Action | Minimum role or token |
|---|---|
| Protect a package | The Maintainer or Owner role. |
| Push a new package | At least the role set in Minimum access level for push. |
| Push a new package with a deploy token | Any valid deploy token, only if the pushed package is not matched by a protection rule. Protected packages cannot be pushed with a deploy token. |
| Delete a package | At least the role set in Minimum access level for delete. |
{{< history >}}
{{< /history >}}
Prerequisites:
To protect a package:
*).The package protection rule is created, and appears in the settings.
You can use a wildcard to protect multiple packages with the same package protection rule. For example, you can protect all the temporary packages built during a CI/CD pipeline.
The following table contains examples of package protection rules that match multiple packages:
| Package name pattern with wildcard | Matching packages |
|---|---|
@group/package-* | @group/package-prod, @group/package-prod-sha123456789 |
@group/*package | @group/package, @group/prod-package, @group/prod-sha123456789-package |
@group/*package* | @group/package, @group/prod-sha123456789-package-v1 |
It's possible to apply several protection rules to the same package. If at least one protection rule applies to the package, the package is protected.
{{< history >}}
{{< /history >}}
Prerequisites:
To unprotect a package:
The package protection rule is deleted, and does not appear in the settings.