Add UPDATE secrets permission action and deprecate WRITE
What does this MR do and why?
This MR adds an UPDATE action to Secrets Manager permissions and marks WRITE as deprecated in the GraphQL API.
The breaking change is approved in gitlab-com/Product#14589. The deprecation announcement is !260975 (merged). Both MRs must merge in 19.6.
WRITE is a Rails name for create + update. OpenBao has no WRITE capability, only create and update. This MR lets API clients grant update on its own name, so the API matches the Create and Update scopes in the UI.
| Client sends | Stored in OpenBao (data path) | Reads back as |
|---|---|---|
UPDATE (new) |
update |
UPDATE |
CREATE + UPDATE (new) |
create, update |
WRITE |
WRITE (deprecated) |
create, update |
WRITE (no change) |
CREATE |
create |
CREATE (no change) |
A create + update grant still reads back as WRITE until WRITE is removed in 20.0. So existing API clients see no change in what they read. The only new output is UPDATE, for an update-only grant.
Code changes
base_secrets_permission.rb:- Add the
updateaction. It grantsupdateon the data path and the metadata path. - In the readback, an update-only grant returns
update. Before this MR, it returned nothing. - When a client sends
createandupdatetogether, the model storeswrite. The mutation response and the list query then both returnWRITE. write,create, and the default role grants do not change.
- Add the
action_enum.rb: addUPDATE. MarkWRITEas deprecated in 19.6.constants.js(permissions table): add theUPDATEscope and itsUpdatelabel, so an update-only grant shows in the Scope column.- Specs: model capability and readback cases, the enum, the permissions table, and an update-only grant in the project and group secret update request specs.
- Generated GraphQL reference docs and introspection files.
Update-only grants
The API does not stop a client from sending UPDATE without CREATE. OpenBao enforces this grant correctly, and the readback shows it as UPDATE. Product and UX decided to allow update-only grants. See #632994 (comment 4025816771) and #632994 (comment 4044161309). The UI switch to send UPDATE is tracked in #633683 (closed).
Danger multiversion warning
Danger flags this MR because it changes both GraphQL backend and frontend code. The change is safe during a rolling deploy:
- The frontend change only adds a label for the
UPDATEvalue it reads from the API. The frontend does not sendUPDATE. The Create and Update scopes in the UI still sendWRITE. - New backend with old frontend: an update-only grant made through the API shows
, Read metadatain its Scope cell instead ofRead metadata, Update. The old frontend has no label forUPDATE, so it sorts first and renders as an empty string. The grant itself works. The label appears once the frontend deploys. !270256 (merged) filters unknown actions so this cannot happen again when a new action is added orWRITEis removed. - New frontend with old backend: the API never returns
UPDATE, so the new label is unused.
References
- Tracking work item: #632994
- Deprecation announcement: !260975 (merged)
- Work item: #630995 (closed)
- Follow-up MR for the non-blocking frontend review suggestions: !270256 (merged)
Screenshots or screen recordings
The only UI change is the Scope cell in the Secrets Manager permissions table. An update-only grant now shows Read metadata, Update. Before this MR, the cell showed Read metadata only. The UI still sends WRITE for the Create and Update scopes.
How to set up and validate locally
-
Use a project with GitLab Secrets Manager enabled, a secret, and a Reporter user. A Reporter has no Secrets Manager grant by default, so every action comes from the grant in step 2.
-
As an Owner, grant the Reporter update-only access in GraphiQL:
mutation { projectSecretsPermissionUpdate(input: { projectPath: "your-group/your-project" principal: { id: <USER_ID>, type: USER } actions: [READ, UPDATE] }) { secretsPermission { actions } errors } }It reads back as
["READ", "UPDATE"]. -
As the Reporter, edit the secret. This works.
-
As the Reporter, try to create a new secret. Secrets Manager denies it, because the grant has no
create. -
As the Owner, open Settings > Secrets Manager > Permissions. The Reporter row shows
Read metadata, Update. -
Grant
[READ, CREATE, UPDATE]. The mutation returns["READ", "WRITE"], and the table showsRead metadata, Create, Update. -
Grant
[READ, WRITE]. The response and the table are the same as in step 6. ExistingWRITEclients see no change.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.