Immutable solution version
Targeting multiple resources with one policy
Complete solution
A practical guide for Cerbos. You can share one policy across multiple resource kinds with scopes. Put the common rules on the parent scope and the per-kind overrides in child scopes, with lenient scope search turned on so a missing scoped rule falls back to the parent.
The problem
Issue cerbos/cerbos#1740 (closed, 5 comments): ### Is there an existing issue for this? - [X] I have searched the existing issues ### Feature description I'd like to attach a resource policy to multiple resources. Right now, a resource policy can only apply to one resource. ### What would the ideal solution look like to you?
The fix
You can share one policy across multiple resource kinds with scopes. Put the common rules on the parent scope and the per-kind overrides in child scopes, with lenient scope search turned on so a missing scoped rule falls back to the parent. That was the maintainer-confirmed pattern in the thread.
Notes
Thread: https://github.com/cerbos/cerbos/issues/1740. Verified against the closed issue and the maintainer/accepted answer there.
Evidence
In https://github.com/cerbos/cerbos/issues/1740, the reporter asked: Issue cerbos/cerbos#1740 (closed, 5 comments): ### Is there an existing issue for this? - [X] I have searched the existing issues ### Feature description I'd like to attach a resource policy to multiple resources. Right now, a resource policy can only apply to one resource. ### What would the ideal solution look like to you? The verified answer: You can share one policy across multiple resource kinds with scopes. Put the common rules on the parent scope and the per-kind overrides in child scopes, with lenient scope search turned on so a missing scoped rule falls back to the parent. That was the maintainer-confirmed pattern in the thread. Source thread: https://github.com/cerbos/cerbos/issues/1740
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_5RhD-gSHRitDnEAVbCy1mw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Targeting multiple resources with one policy <span>— Vectle</span></a>