Skip to content

Commit efde704

Browse files
committed
Nive JSON comments in Cedar policy example above the example
Remove inline // comments from JSON code block as they are invalid JSON syntax and will cause parsing errors. Move explanations to bullet points above the example for better clarity.
1 parent ffd5eda commit efde704

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

docs/toolhive/_partials/_basic-cedar-config.mdx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
Create a JSON or YAML file with Cedar policies. Here's an example in JSON
2-
format:
1+
Create a JSON or YAML file with Cedar policies. This example demonstrates
2+
several policy patterns:
3+
4+
- Allow everyone to use the weather tool
5+
- Restrict admin_tool to a specific user (alice123)
6+
- Role-based access: only users with the 'premium' role can call any tool
7+
- Attribute-based: allow calculator tool only for add/subtract operations
8+
9+
Here's an example in JSON format:
310

411
```json
512
{
613
"version": "1.0",
714
"type": "cedarv1",
815
"cedar": {
916
"policies": [
10-
// Allow everyone to use the weather tool
1117
"permit(principal, action == Action::\"call_tool\", resource == Tool::\"weather\");",
12-
// Restrict admin_tool to a specific user
1318
"permit(principal == Client::\"alice123\", action == Action::\"call_tool\", resource == Tool::\"admin_tool\");",
14-
// Role-based access: only users with the 'premium' role can call any tool
1519
"permit(principal, action == Action::\"call_tool\", resource) when { principal.claim_roles.contains(\"premium\") };",
16-
// Attribute-based: allow calculator tool only for add/subtract operations
1720
"permit(principal, action == Action::\"call_tool\", resource == Tool::\"calculator\") when { resource.arg_operation == \"add\" || resource.arg_operation == \"subtract\" };"
1821
],
1922
"entities_json": "[]"

0 commit comments

Comments
 (0)