rego4k debugger
Query
decision := data.documents.filter.visible
Write a policy, an input and a query. Then click Debug.
# The documents of the library that the user can read. The document store asks for `visible` and shows only # these documents, so the policy filters the data and does not only answer yes or no. package documents.filter levels := {"public": 0, "internal": 1, "confidential": 2} visible contains {"id": document.id, "title": document.title} if { some document in data.documents.library readable(document) } # Each user can read a public document. readable(document) if document.classification == "public" # A user can read a document of the department of the user, up to the clearance of the user. readable(document) if { document.department == input.user.department cleared(document) } # An auditor can read a document of each department, up to the clearance of the auditor. readable(document) if { input.user.role == "auditor" cleared(document) } cleared(document) if levels[document.classification] <= levels[input.user.clearance]
Input (JSON)
{ "user": { "clearance": "internal", "department": "engineering", "name": "alice", "role": "engineer" } }