rego4k debugger
Query
decision := data.httpapi.authz.decision
Write a policy, an input and a query. Then click Debug.
# The tests of the policy. `opa test` runs them, and `just test-rego` with rego4k. `DemoBundlesTest` runs them as JUnit # tests. The debugger offers the input of each test as an example. package httpapi.authz_test import data.httpapi.authz test_viewer_reads_a_report if { authz.allow with input as {"method": "GET", "path": "/reports/q3", "user": "alice"} } test_viewer_cannot_edit_a_report if { not authz.allow with input as {"method": "PUT", "path": "/reports/q3", "user": "alice"} } test_user_reads_own_profile if { authz.allow with input as {"method": "GET", "path": "/users/bob", "user": "bob"} } test_unknown_user_has_no_roles if { authz.decision == {"allow": false, "roles": []} with input as {"method": "GET", "path": "/reports/q3", "user": "mallory"} } # Each case is a test of its own, with the note as its name. test_permissions[tc.note] if { some tc in [ {"note": "an editor edits a report", "user": "bob", "method": "PUT", "path": "/reports/q3", "allow": true}, {"note": "an editor cannot delete a report", "user": "bob", "method": "DELETE", "path": "/reports/q3", "allow": false}, {"note": "an admin deletes a user", "user": "carol", "method": "DELETE", "path": "/users/bob", "allow": true}, {"note": "a viewer cannot read another profile", "user": "alice", "method": "GET", "path": "/users/bob", "allow": false}, ] authz.allow == tc.allow with input as {"method": tc.method, "path": tc.path, "user": tc.user} }
Input (JSON)
{ "method": "PUT", "path": "/reports/q3", "user": "alice" }