brew install opa
opa build policy.rego -o bundles/bundle.tar.gz
docker-compose up
This will return false because charlie is not allowed to view alice's salary
curl --location 'http://localhost:8181/v1/data/httpapi/authz' \
--header 'Content-Type: application/json' \
--data '{
"input": {
"user": "charlie",
"path": ["finance", "salary", "alice"],
"method": "POST"
}
}'
response: {"decision_id":"69075630-93d2-4cc1-b1b4-2034a572d78a","result":{"allow":false,"subordinates":{"alice":[],"betty":["charlie"],"bob":["alice"],"charlie":[]}}}
This will be true because alice can view her salary
curl --location 'http://localhost:8181/v1/data/httpapi/authz' \
--header 'Content-Type: application/json' \
--data '{
"input": {
"user": "alice",
"path": ["finance", "salary", "alice"],
"method": "POST"
}
}'
response: {"decision_id":"713f70bd-0c91-4f0c-acd3-706415088cf9","result":{"allow":true,"subordinates":{"alice":[],"betty":["charlie"],"bob":["alice"],"charlie":[]}}}