Commit c10828b
committed
fix(security): PermissionHandler — bypass cache when schema has match rules
The per-request permission cache keys verdicts on
`(schemaId, action, userId, objectOwner, objectUuid)` and reuses them
within the request lifecycle. That is safe for schemas whose
authorization is purely group/role based, but unsafe for schemas
whose auth block contains a `match: { … }` clause: the rule reads
from `$object->getObject()`, which can mutate within a single
request via `saveObject()` / TransitionEngine. A write-then-write
pattern (e.g. batch update) would otherwise return a stale verdict
based on the pre-write field values.
Add `schemaHasMatchRule()` helper that walks the schema's
authorization block once and reports whether any entry carries a
non-empty `match`. `buildPermissionCacheKey()` returns null when it
does, forcing each call to re-evaluate the rule chain against fresh
object data. Cost: a hot-path per-request cache miss for the
specific schemas that opt into conditional rules — acceptable trade
versus the correctness regression.
Refs: #1419 review (concern 5) — discussion_r31874944741 parent bb8cd7f commit c10828b
1 file changed
Lines changed: 54 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
| 214 | + | |
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
| |||
253 | 254 | | |
254 | 255 | | |
255 | 256 | | |
256 | | - | |
| 257 | + | |
| 258 | + | |
257 | 259 | | |
258 | 260 | | |
259 | 261 | | |
260 | 262 | | |
261 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
262 | 275 | | |
263 | 276 | | |
264 | 277 | | |
| |||
278 | 291 | | |
279 | 292 | | |
280 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
281 | 333 | | |
282 | 334 | | |
283 | 335 | | |
| |||
0 commit comments