Role-based authorization for a Todo application, based on the AuthZEN Interop Todo scenario.
Authorization Matrix
Section titled “Authorization Matrix”| Action | admin (Rick) | evil_genius (Rick) | editor (Morty, Summer) | viewer (Beth, Jerry) |
|---|---|---|---|---|
can_read_user |
allow | allow | allow | allow |
can_read_todos |
allow | allow | allow | allow |
can_create_todo |
allow | — | allow | deny |
can_update_todo |
allow (any) | allow (any) | allow (own only) | deny |
can_delete_todo |
allow (any) | — | allow (own only) | deny |
Running
Section titled “Running”./opa-authzen-plugin run --server \ --config-file example/todo/config.yaml \ example/todo/policy.rego \ example/todo/users.jsonExample Requests
Section titled “Example Requests”Admin can delete any todo
Section titled “Admin can delete any todo”curl -s -X POST http://localhost:8181/access/v1/evaluation \ -H "Content-Type: application/json" \ -d '{ "subject": {"type": "user", "id": "rick"}, "resource": {"type": "todo", "id": "todo-1", "properties": {"ownerID": "morty@the-citadel.com"}}, "action": {"name": "can_delete_todo"} }'# → {"decision":true}Editor can only update their own todos
Section titled “Editor can only update their own todos”# Morty updating his own todo — allowedcurl -s -X POST http://localhost:8181/access/v1/evaluation \ -H "Content-Type: application/json" \ -d '{ "subject": {"type": "user", "id": "morty"}, "resource": {"type": "todo", "id": "todo-1", "properties": {"ownerID": "morty@the-citadel.com"}}, "action": {"name": "can_update_todo"} }'# → {"decision":true}
# Morty updating Rick's todo — deniedcurl -s -X POST http://localhost:8181/access/v1/evaluation \ -H "Content-Type: application/json" \ -d '{ "subject": {"type": "user", "id": "morty"}, "resource": {"type": "todo", "id": "todo-2", "properties": {"ownerID": "rick@the-citadel.com"}}, "action": {"name": "can_update_todo"} }'# → {"decision":false}Viewer cannot create todos
Section titled “Viewer cannot create todos”curl -s -X POST http://localhost:8181/access/v1/evaluation \ -H "Content-Type: application/json" \ -d '{ "subject": {"type": "user", "id": "jerry"}, "resource": {"type": "todo", "id": "todo-1"}, "action": {"name": "can_create_todo"} }'# → {"decision":false}Batch: check multiple permissions at once (Section 7)
Section titled “Batch: check multiple permissions at once (Section 7)”curl -s -X POST http://localhost:8181/access/v1/evaluations \ -H "Content-Type: application/json" \ -d '{ "subject": {"type": "user", "id": "morty"}, "resource": {"type": "todo", "id": "todo-1", "properties": {"ownerID": "morty@the-citadel.com"}}, "evaluations": [ {"action": {"name": "can_read_todos"}}, {"action": {"name": "can_update_todo"}}, {"action": {"name": "can_delete_todo"}} ] }'# → {"evaluations":[{"decision":true},{"decision":true},{"decision":true}]}© 2026 The opa-authzen-plugin Authors. Licensed under Apache-2.0. Part of dyokto.