Write-only secrets cannot be queried (review B-R1)
A where or sort on a write-only field answered by the stored value: as an admin, where[version.smtpPassword][like]=Zq on Site integrations' versions gave a count, so the secret could be read back one character at a time. writeOnlySecret now gives the field a read rule, secretReadAccess (exported), that denies when Payload checks a query's fields (no document) and allows a document read (masked as before). The panel's edit and create views pass the document, so the field stays visible and editable there. Covered: the global, its versions, a collection with and without versions, REST and GraphQL, like / equals / exists / or / sort / count; reads still masked; panel permissions; a save still stores the new value. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ecf03c8dc0
commit
eb2ad27787
@@ -1063,6 +1063,14 @@ document, the fields under `version`, where field hooks do not run: the global's
|
||||
value is set"; the API returns the mask. Code of your own that read the secret over REST / GraphQL as an admin
|
||||
must read it on the server with the Local API instead.
|
||||
- **Off:** `iapl({ secrets: { writeOnly: false } })` — the value is returned to whoever may read the global.
|
||||
- **A query cannot name a secret (1.17.1).** A `where` or `sort` on a write-only field answers by the stored value
|
||||
(`where[version.smtpPassword][like]=Zq` gave a count), so an admin could read the secret back one character at a
|
||||
time. `writeOnlySecret` now gives the field a `read` rule, `secretReadAccess`, that refuses a query naming it —
|
||||
REST and GraphQL, `like` / `equals` / `exists` / `sort`, on the document and its versions (an error, no count) — while
|
||||
every read of a document still answers the mask and the panel shows and saves the field as before. Payload checks a
|
||||
query's fields without a document and asks rules that depend on one to deny then; the panel always passes the
|
||||
document. The field's own `access.read` is kept and decides for a document. Not in collection list columns or
|
||||
list filters. Server code with `overrideAccess` (the Local API) may still query it.
|
||||
- **Your own secret fields:** `writeOnlySecret({ name: 'apiToken', type: 'text', admin: { components: { Field:
|
||||
'@intecion/ipal-kit/admin#MaskedField' } } })`, or `writeOnlySecrets(fields, ['apiToken'])` for fields inside
|
||||
tabs / rows / groups; the hooks `maskSecretAfterRead` / `keepSecretBeforeValidate`, `SECRET_MASK`,
|
||||
|
||||
Reference in New Issue
Block a user