Skip to content

Instantly share code, notes, and snippets.

@RajputVaibhav
Created June 7, 2020 10:26
Show Gist options
  • Save RajputVaibhav/d9a043a0b07d80e20e309419f715ee9c to your computer and use it in GitHub Desktop.
Save RajputVaibhav/d9a043a0b07d80e20e309419f715ee9c to your computer and use it in GitHub Desktop.
This is a simple OPA policy written in Rego. For context check the Medium blog
package play
default allow = false
allow = true {
input.method = "GET"
input.path = ["salary",employee_id]
input.user = employee_id
}
allow = true {
input.method = "GET"
input.path = ["salary",employee_id]
input.user = employee_id
}
managers = {
"gilfoyle": {"richard","erlich"},
"richard": {"erlich"},
}
test_allow {
allow with input as {"method": "GET", "user": "richard", "path": ["salary","gilfoyle"]}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment