I am trying to use OPA as authorization service for Trino. I wrote a rego file according to my needs.
package mytrino
import rego.v1
default allow := false
allow if {
input.action.operation == "ExecuteQuery"
not input.action.resource
}
allow if {
input.action.operation == "AccessCatalog"
}
allow if {
input.action.operation == "FilterCatalogs"
}
allow if {
input.action.operation == "FilterSchemas"
}
allow if {
input.action.operation == "SelectFromColumns"
input.action.resource.table.catalogName == "system"
}
allow if {
response := http.send({
"method": "post",
"url": "http://host.docker.internal:8085/api/products/check-table-access",
"headers": {"Content-Type": "application/json"},
"body": {
"user": input.context.identity.user,
"table": input.action.resource.table.tableName
}
})
response.status_code == 200
}
I was checking my API logs and I saw there have been requests that are 100% percent true without the last allow if statement. So I think even though the previous allow if's are true, it evaluate subsequent statements?
How can I prevent final allow if statement to make http requests if the previous ones are true?
Thank you a lot!