Slackbot
09/11/2023, 4:34 PMThilak Reddy
09/11/2023, 4:34 PMpackage httpapi.authz
default allow = false
allow {
input.method = "POST"
input.path = ["v1", "users"]
}
calling OPA with following request payload
curl --location --request POST '<http://localhost:8181/v1/data/httpapi/authz>' \
--header 'Content-Type: application/json' \
--data-raw '{
"input": {
"method": "POST",
"path": [
"v1",
"users"
]
}
}'
should have resulted in
{
"result": {
"allow": true
}
}
instead i don’t get anything in response
not sure if data source fetch failing causes any issues with OPA’s working
if not would help me to rule out this possibility and debug differentlyThilak Reddy
09/11/2023, 4:46 PMAsaf Cohen
09/11/2023, 4:53 PMAsaf Cohen
09/11/2023, 4:56 PMThilak Reddy
09/11/2023, 5:08 PMdocker run -it \
-e "OPAL_POLICY_UPDATER_ENABLED=false" \
-e "OPAL_INLINE_OPA_LOG_FORMAT=http" \
-e "OPAL_SERVER_URL=<http://host.docker.internal:7002>" \
-e "OPAL_INLINE_OPA_CONFIG="{\"files\":[\"\/policy.rego\"]}"" \
-p 7766:7000 -p 8181:8181 opal-local
i built this opal-local image from latest image and load my policy file into the image
FROM permitio/opal-client:0.7.4-rc
COPY ./policy/org.rego /policy.rego
my server docker run is
docker run -it \
-e "OPAL_POLICY_REPO_URL=<https://github.com/thilak009/opal-policy-store-test>" \
-e OPAL_DATA_CONFIG_SOURCES=<config> \
-e "OPAL_POLICY_REPO_POLLING_INTERVAL=0" \
-e "OPAL_POLICY_REPO_MAIN_BRANCH=main" \
-e "OPAL_REPO_WATCHER_ENABLED=false" \
-p 7002:7002 permitio/opal-server:0.7.4-rc
the DATA_CONFIG_SOURCES has url of a proxy/gateway which serves data, but this fails due to some reasonThilak Reddy
09/11/2023, 5:12 PMAsaf Cohen
09/11/2023, 5:17 PMthe DATA_CONFIG_SOURCES has url of a proxy/gateway which serves data, but this fails due to some reasonthe logs would be helpful here
Asaf Cohen
09/11/2023, 5:19 PMcurl --location --request GET 'http://<pdp-dns>:8181/v1/policies'
and see if your policy is indeed loaded as expectedThilak Reddy
09/12/2023, 5:14 AMcase condition1,condition1,conditionn:
// code to be executed
and not
case condition1:
case condition2:
case conditionn:
// code to be executed
shouldn’t have debugged this yesterday when my brain battery was low xDAsaf Cohen
09/12/2023, 9:55 AM