Allow Update secrets permission without Create
What does this MR do and why?
Lets Owners grant the Update secrets permission without also granting Create. A new update permission action maps to OpenBao update on the data and metadata paths, and the permissions modal no longer ties the Update checkbox to Create.
This MR also moves the Delete secrets permission to the bottom of the permissions modal UI.
🤖 Justification
- Before this change, an update-only grant was deliberately not representable:
writemeant create + update, and the modal disabled Update unless Create was checked. - The update flow needs only
updateon the data path andupdateon the metadata path.UpdateServicealready reads metadata withwrite_capability: update(added in !264890 (merged)), so no read grant is needed. - Backend (
BaseSecretsPermission):- Adds
updatetoACTIONS, mapped to dataupdateand metadataupdateinmanagement_capabilities. actions=collapsescreate+updateintowriteand dropscreate/updatewhenwriteis present, so a readback matches the grant.set_actions_from_capabilitiesemitswrite(create + update),create(create only) orupdate(update only).
- Adds
- GraphQL: adds
UPDATEtoSecretsManagementActionand regeneratesdoc/api/graphql/reference/enums.md. The legacypermissionsstring onSecretPermissionalready passesupdatethrough. - Frontend:
- The Update checkbox is enabled whenever Read metadata is checked, and the watcher that cleared it when Create was unchecked is removed.
- Submitted actions are: create + update =>
WRITE, update only =>UPDATE, create only =>CREATE. - The permissions table labels an
UPDATEgrant as "Update". No new locale strings were needed.
- Docs:
services.md,openbao_client.md, the Secrets Manager user doc, and the permissions tables indoc/user/permissions.md.
References
- Open MRs
- !260976 (merged) Add
UPDATEsecrets permission action and deprecateWRITE(open) - !260975 (merged) Deprecate WRITE secrets permission action (open, the docs side of the same change)
- !260976 (merged) Add
- Merged MRs
- !260923 (merged) Replace Write scope with Create and Update in secrets modal (merged)
- !260855 (merged) Show Write secrets scope as Create, Update (merged)
- !254325 (merged) Add create-only action for Secrets Manager permissions (merged)
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
- Enable Secrets Manager for a group - or select a project and provision it.
- Visit the permissions table.
- For groups go to Settings > Secure > GitLab Secrets Manager and select Add under User permissions
- For projects go to Settings > General > Visibility, project features, permissions > GitLab Secrets Manager and select Add under User permissions.
- Select a Reporter or Developer user and check Read metadata and Read value. Update is now enabled without Create.
- Check only Update and save. The table shows "Read metadata, Read value, Update".
- Check Create and Update together and save. The table shows "Create, Update" (the
WRITEaction). - As the update-only user, update an existing secret (this succeeds), then try to create a new secret (this is denied).
🤖 Testing
- Jest:
yarn jest ee/spec/frontend/pages/projects/shared/permissions/secrets_managerran locally. The modal and table specs pass, along with all other suites in that directory except the failure below. - Existing failure:
secret_manager_settings_spec.js› "renders skeleton loader" fails identically on a cleanmaster, so it is unrelated to this change. - ESLint on the touched JS and Vue files reported only graphql-eslint schema-loading errors on untouched
.graphqlfiles, becausetmp/tests/graphql/gitlab_schema_apollo.graphqlis not generated locally. Prettier passes. - RuboCop passes on the touched Ruby files.
- Not run locally: the RSpec specs (model shared examples, permission update and list services, GraphQL mutation and enum, project and group
UpdateService). They need PostgreSQL and OpenBao, which were not available. CI is the first real run of them.- A standalone Ruby check of
actions=,management_capabilitiesandset_actions_from_capabilitiesgave the expected results.
- A standalone Ruby check of
- Specs added or updated:
- Model shared examples: update-only now maps to
updateinstead of emitting no write action, plusactions=normalization cases. - Permission update service: update-only policy capabilities.
- Permission list service: update-only readback.
- GraphQL mutation: update-only grant.
- GraphQL enum spec:
UPDATEvalue. - Project and group
UpdateService: a user withupdate+read_valuecan update an existing secret but cannot create one. - Jest: Update enabled without Create; payloads for update-only, create-only, and create + update.
- Model shared examples: update-only now maps to
🤖 Risk
Low. Existing grants are unaffected, and no migration is needed because permissions live in OpenBao policies and are read back from them. The write, create, read and delete mappings are unchanged. The only new behavior is the new update action: a policy with update and no create is now read back as update instead of dropping the write action.
How to revert
Revert this MR. Any update-only policies created in the meantime would then read back with no write action, and affected users would need their permission re-saved.
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.