Hey Folks, I appear to have stumbled upon a OPAL ...
# opal
k
Hey Folks, I appear to have stumbled upon a OPAL - Cedar bug. If a policy file contains more than one rule, the publishing of rules from OPAL to the cedar agent does not complete. Logs don't show any errors and it just fails silently. You can replicate the problem by doing the following: Launch the cedar integration compose file: https://github.com/permitio/opal/blob/master/docker/docker-compose-example-cedar.yml as per the tutorial: https://docs.opal.ac/tutorials/cedar/ Confirm data is present at: http://localhost:8180/v1/policies (cedar agent) Confirm data is present at: http://localhost:7002/policy (opal server) now... modify the example file to have more than one rule. i.e. https://github.com/permitio/opal-example-policy-repo/blob/master/policy.cedar Update the file to have another rule:
Copy code
permit(
    principal in Role::"Editor",
    action in [
        Action::"document:read",
        Action::"document:write",
        Action::"document:delete"
	],
    resource in ResourceType::"document"
);

permit(
    principal in Role::"LimitedEditor",
    action in [
        Action::"document:read",
        Action::"document:write",
	],
    resource in ResourceType::"document"
);
Start up the stack. You'll notice the cedar agent returns empty: http://localhost:8180/v1/policies (cedar agent) Confirm data is present at: http://localhost:7002/policy (opal server)
a
Hi @Kirk Daries, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
(1) This appears to be a legitimate issue with OPAL's Cedar integration when handling multiple policies. Based on the OPAL + Cedar tutorial , the expected behavior should allow multiple Cedar policies to be synchronized from OPAL to the Cedar agent. The tutorial shows how to run the Cedar configuration with Docker Compose :
Copy code
git clone https://github.com/permitio/opal.git  
cd opal  
docker compose -f docker/docker-compose-example-cedar.yml up -d
The documentation indicates that you should be able to show policies with a GET request to
/policies
, and your observation that single policies work but multiple policies fail silently suggests a synchronization issue between OPAL and the Cedar agent. To help our engineers investigate this issue, could you please provide: 1. Which Workspace / Project / Env you are using 2. What calls are you performing (as SDK code or CURL) 3. Which PDP version you are running 4. To share relevant logs from your PDP Additionally, you might want to check the OPAL server logs for any warnings or errors during policy synchronization, and verify the Cedar agent logs to see if there are any parsing errors when processing multiple policies. This issue is worth reporting to the OPAL project since it affects the core functionality of policy synchronization between OPAL and Cedar agents (1) (2) .
To learn more, see the sources I considered: [[1] Cedar-Agent and Cedar](https://docs.opal.ac/tutorials/cedar) [[2] ⚡OPAL⚡](https://github.com/permitio/opal/blob/master/README.md)
o
Hey @Kirk Daries , as of now the OPAL<> Cedar Agent integration allows only one policy per file, the reason for that is that every policy rule must have an id in cedar, in order for the integration to stay consistent and predictable in creation, edition and deletion we decided to use the file name as the policy id. This decision limits the number of rules in a file to one
k
okay. kind of counter intuitive, as you go from the cedar playground where its allowed and you evaluate a 'policy domain' / group of rules to splitting up the files when it comes to integrating it with OPAL. I don't think its a show stopper but its def annoying. This is a very different experience when using OPA and OPAL and i would have hoped for some feature parity in that regard
o
It is an issue we are aware of and we started discussing it when it first came up. If you’d like I can guide you on a contribution to fix that ( which can be isolated to cedar agent alone )
k
Thanks Omer. I may ultimately lean upon you for that. Let me discuss with my stakeholders and i'll get back to you (I have my own priorities with the POC at the moment... ) I thought about it a bit more and i remember that i submitted a full rules domain to cedar-agent and tested that directly and didn't encounter this issue. Its ... unfortunate that OPAL has this behaviour right now.