Make read_metadata a real boundary for secrets

What does this MR do and why?

Every Secrets Manager grant could list the names and metadata of all secrets, because Rails added list and scan to every policy. And create, update and delete failed without read_metadata, because they read the secret as the user first. This makes read_metadata a real boundary and lets those writes work without it.

Details
  • Policies: list on the metadata and detailed-metadata paths only with read_metadata (or read). scan is gone (Rails never used it). The read_value API policy keeps list on metadata (key names) but no longer lists detailed metadata. Paths with no capabilities stay in the policy so the list service still reads granted_by and the expiry. OpenBao accepts them, and they grant nothing.
  • Reads before writes: ReadMetadataService takes write_capability:. It reads as the user. Only when OpenBao denies that read and capabilities-self shows the user holds the capability on that secret does it re-read with the app client. The write still runs as the user. Rails abilities for these mutations start at Reporter, so the capability check is what stops a user with no grant from probing metadata.
  • EffectiveCapabilitiesService already treats detailed-metadata list as read_metadata, so userPermissions.readMetadata is now accurate.

References

Screenshots or screen recordings

No UI changes. Users without read_metadata now see the existing "no read access" state on the secrets page.

How to set up and validate locally

  1. As an Owner, grant a Reporter create and read_value on a project with Secrets Manager active.
  2. As that Reporter, create a secret through the projectSecretCreate mutation. It succeeds (it failed before).
  3. As that Reporter, query projectSecrets. It returns "resource not available" (it listed every secret before).

Testing

Not run locally: native gems don't build on this machine (macOS SDK linker error). Specs added for the policy shape, create, update and delete with a write grant plus read_value, the denied cases, and the read fallback. CI runs them.

Risk

  • Existing grants in OpenBao keep list and scan until edited. A follow-up will rewrite them.
  • After the fallback, a successful update or delete returns the secret's metadata to a writer without read_metadata who knows the name. Accepted: they can already overwrite that metadata.
  • Users with only write grants lose the secrets page. They can still use the API.

How to revert

Revert this MR. No migration, and policies written while it was live keep working because they only have fewer capabilities.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

Edited by Mark Mishaev

Merge request reports

Loading
Loading