Undefined Is Not False
An API asks OPA for a decision on every request.
package authz
import rego.v1
allow if {
input.action == "read"
input.subject.tenant == input.resource.tenant
}
// POST http://opa:8181/v1/data/authz -> { "result": { ... } }
const res = await fetch(OPA_URL, {
method: 'POST',
body: JSON.stringify({ input })
})
const { result } = await res.json()
if (result.allow === false) {
return reply.code(403).send()
}
return handler(req, reply)
A user in tenant acme requests a resource in tenant kestrel. What happens?
Sign in to answer questions and track your progress
Sign In