How should repository permissions be split so CI can deploy to a staging repository but only a promotion identity can write to release?
answer
- two identities, two scopes
- CI: write staging, read release
- promoter: read staging, write release
- nobody overwrites or deletes release
- metadata writers can promote too
basics
~20 sGive the CI identity write access to staging and only read access to release, and give a separate promotion identity read on staging and write on release, with no overwrite or delete there. The repository manager then logs every promotion.
solid answer
~40 sUse two non-human identities. The **CI token** can deploy to the staging repository and only read release. The **promotion identity**, such as a Harbor robot account or a scoped Artifactory token, can read staging and write release, and nothing else; no identity gets overwrite or delete on release in normal operation. People approve, but the promotion job performs the write, so the release repository only ever receives artifacts through one controlled path. Check the metadata route too: if promotion is a property or label, whoever may set it can promote, and that is Artifactory's Annotate permission or Harbor's Developer role. The record of who promoted what comes from the manager's audit log plus properties stamped on the artifact.
go deeper
Recall the split: CI writes staging and reads release, a separate promotion identity writes release, and nobody overwrites or deletes there in normal work.
Explain how a product expresses it, such as Harbor's read-on-source and write-on-target rule for copies, project versus system robot accounts, and Artifactory's Annotate permission for properties.
Audit a real setup for leaks: shared tokens, personal credentials used for promotion, delete rights on release, or a label anyone with Developer can set.
Decide where the organisation's promotion boundary sits, repository permissions or metadata, and what record an auditor will accept, then make every team inherit it.
## Why permissions are the real promotion gate A **release repository** is only trustworthy if an artifact can reach it in exactly one way: promotion from staging after approval. If CI can also deploy straight into release, a build that never passed QA can appear there, and the repository's name proves nothing. The permission model is what turns "release" from a label into a boundary. ## The two identities Use two **non-human identities**, each scoped to the minimum it needs: | Identity | Staging repository | Release repository | |---|---|---| | CI deploy token | read and write (deploy) | read only | | Promotion identity | read | write, no overwrite, no delete | | People | read | read | - The **CI token** deploys every candidate into staging. It can read release so builds can depend on released components, but it cannot publish there. - The **promotion identity** reads the approved artifact from staging and writes it into release. It is used only by the promotion job, so its use in a log means "a promotion happened". - **People** approve the candidate, but they do not hold the write credential; the job does the write after the approval is recorded. - **Overwrite and delete** on release are kept from everyone in normal operation and granted only through a break-glass procedure. ## How the products express it - **Harbor** scopes permissions per **project**. Copying an artifact from one project to another needs **read** permission (Guest role or above) in the source project and **write** permission (Developer role or above) in the target. A **project robot account** can act only inside the project it was created in; a **system robot account**, created by a system administrator, can be granted permissions across several projects, which suits a promotion identity that reads `develop` and writes `release`. Robot accounts authenticate with a secret and cannot log in to the web interface. - **Artifactory** grants permissions on repositories (and paths within them) through permission targets, and creating repositories needs Admin or Project Admin. Separate local repositories per stage, which its naming guidance encourages (`<team>-<tech>-<maturity>-<locator>`), make the split a matter of which repositories each identity may write. - **Nexus Repository** can apply the same split, granting each identity rights per hosted repository. ## The metadata loophole If promotion is a **property** or **label** rather than a copy, the permission that matters is the right to write metadata, not the right to deploy: 1. In **Artifactory**, adding or editing properties needs the **Annotate** permission, and the documentation says property values are guidance rather than strictly enforced. 2. In **Harbor**, the **Developer** role and above can add and remove labels on images. 3. So in a metadata-based model, any CI token or developer granted those rights can mark an artifact released. Either restrict that right to the promotion identity, or use a repository boundary for enforcement and metadata only for the record. ## The promotion record An auditor will ask: which artifact, approved by whom, promoted by what, when. A good record has: - the **checksum or digest** of the promoted artifact, so the record names bytes, not just a version; - the **source and target** repositories; - the **identity** that performed the write and the **approval reference** that authorised it; - the **time**. Two places hold it. The repository manager's own log: Harbor's audit log records event types such as `push artifact` and `delete artifact` with timestamp, username and resource, and project logs can be filtered by operation. And **metadata on the artifact itself**: Artifactory properties can carry the build number, revision or ticket, set at deploy time with matrix parameters such as `;buildNumber=249;revision=1052` and added at promotion. Metadata travels with the artifact and is searchable; the audit log is harder to tamper with. Use both. ## Mistakes to avoid - One shared CI token with write access everywhere, which makes the release boundary decorative. - A human's personal credential used for promotion, so the record shows a person, not a process, and access leaves with them. - Granting delete on release "for cleanup", which lets anyone remove what production pins. - Forgetting that the metadata permission is a promotion permission in a property-based model.
- Why should the promotion identity be a robot or service account rather than the approver's own account?Because the approval and the write are different facts. The approver's decision is recorded by the approval system; the write is performed by one narrowly scoped identity whose only use is promotion. That keeps write access to release out of personal accounts, makes the log easy to read, and survives people changing roles.
- When would you still allow anyone to delete from the release repository?Only through a break-glass procedure: a separate, audited role granted for a specific incident, such as removing an artifact with a legal or security problem. Normal cleanup of release should be driven by an agreed retention policy that excludes anything still deployed, not by broad delete rights.
- CI needs write on release so builds can publish faster.
- The approver's personal account should perform the promotion write.
- Property-based promotion needs no permission design of its own.
- Granting delete on release is harmless if people are careful.
- A version number alone is enough for the promotion record.