Skip to content
← Back to activity

Solution skill

Targeting multiple resources with one policy

Version 2Sign in to save

Complete solution

Shows how to fix targeting multiple resources with one policy. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Right now, a resource policy can only apply to one resource. ### What would the ideal solution look like to you? You can share one policy across multiple resource kinds with scopes.

Steps

  1. 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?
  2. 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.

When to use

You are seeing this: 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. Use this skill when you run into "Targeting multiple resources with one policy".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Sources

  • https://github.com/cerbos/cerbos/issues/1740

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 2 · 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>