Admin credential editor can't scope "Sandbox environment variable" credentials, and says grants don't apply to them
Summary
In Settings → Credentials → Add credential, "Who can use it" (Everyone / Specific people or channels) only appears for Proxied by QM delivery. When Sandbox environment variable is selected, the picker is replaced by "Every all-internal conversation gets the variable. It isn't limited by grants.", and the credential is always saved with the org as its only grantee. Core does gate env delivery by grants. Only the editor ignores them. So an admin who wants an env key for one person, team or channel can't set that up in the UI. They have to share it with the whole org. If the grants were set through the API, the next save in the editor resets them to org-wide without any warning.
Steps to reproduce
- As an org admin, open Settings → Credentials → + Add credential.
- Choose Delivery Sandbox environment variable, set a variable name and a secret.
- Look at Access: there is no "Who can use it" control, and the summary reads "Every all-internal conversation; grants don't gate env delivery".
- Save. The credential's grantees are
["org:<org>"]. - Optional: set narrower grantees through
PUT /api/scopes/<org>/service-credentials(delivery: "env",grantees: ["personal:U1"]), then open and save the credential in the editor. Grantees go back to["org:<org>"]. Expected: env credentials offer the same Everyone / Specific people or channels choice as proxied credentials, and saving keeps it.
Where (at efcbae65e)
UI, plugins/web-ui/src/admin/settings-credentials.ts:
- L162:
grantees: env ? [this.scope] : this.grantees(),replaces whatever was selected with the org. - L174–176: the "at least one person" and resolution checks skip env.
- L206, L660: "grants don't gate env delivery" / "It isn't limited by grants."
- L441: the access badge is hidden for env rows, so an env credential with narrower grants looks org-wide in the list. Core already enforces grants for env:
src/api/routes/admin-resources.tsL1021: the save handler accepts and storesgranteesfor both deliveries.src/core/orchestrator/credential-catalog.tsL316: only granted credentials are offered (granted.has(record.slug)), env included. At L364–371 the env branch re-checks withauthorizeServiceCredentialbefore injecting, and L148 requires an ACL grant.test/orchestrator-credentials.test.tsL533: "env-delivery credentials are gated by service-cred grants — no grant, no env var; a person grant admits only that person". The same claim is inskills-seed/browse/SKILL.mdL23 ("it rides into every all-internal conversation").
Suggested fix (UI only, no schema or API change)
collect():grantees: this.grantees()for both deliveries.validate(): apply the "Add at least one person or choose org-wide access." and resolution checks to both deliveries.credentialsCard(): render "Who can use it" for both. Keep only the "Published apps" switch broker-only.capability().principals: list the grantees for env too, without the published-apps suffix.credentialFlags(): show the grantee-count badge for env rows.- Copy: delivery help "Injected into the all-internal conversations it's shared with. Rooms with external guests get nothing."; browse skill "…every all-internal conversation it's shared with…".
Existing env credentials already have the org grant, so they open as "Everyone" and behave the same as before. No migration needed.
A unit test in
plugins/web-ui/test/admin/setting-modules.test.ts:begin()an env credential with["personal:U1", "channel:C1"]and assert thatcollect().granteeskeeps them. Then cleardraft.peopleand assert thatvalidate()asks for at least one person.