Mohan Prasath
12/17/2022, 12:30 PM/api/check/resources
I'm getting invalid actions on the response.
My Server config
server:
httpListenAddr: ":3592"
adminAPI:
enabled: true
adminCredentials:
username: ''
passwordHash: ''
playgroundEnabled: true
storage:
driver: "mysql"
mysql:
dsn: "user:password@tcp(localhost:3306)/cerbos"
connPool:
maxLifeTime: 60m
maxIdleTime: 45s
maxOpen: 4
maxIdle: 1
request and response from /admin/policy
curl --request GET \
--url '<http://172.31.39.159:3592/admin/policy?id=principal.student.vdefault>'
Response
{
"policies": [
{
"apiVersion": "api.cerbos.dev/v1",
"metadata": {
"hash": "13174666176308465445",
"storeIdentifer": "principal.student.vdefault"
},
"principalPolicy": {
"principal": "student",
"version": "default",
"rules": [
{
"resource": "student-management",
"actions": [
{
"action": "read",
"effect": "EFFECT_ALLOW"
}
]
}
]
}
}
]
}
Now I'm testing the /api/check/resources
curl --request POST \
--url <http://172.31.39.159:3592/api/check/resources> \
--header 'Content-Type: application/json' \
--data '{
"requestId": "c2db17b8-4f9f-4fb1-acfd-9162a02be42b",
"principal": {
"id": "student",
"policyVersion": "default",
"roles": [
"student"
],
"attr": {
"beta_tester": true
}
},
"resources": [
{
"actions": [
"read",
"delete"
],
"resource": {
"kind": "student-management",
"policyVersion": "default",
"id": "XX125",
"attr": {
}
}
}
]
}'
Response
{
"requestId": "c2db17b8-4f9f-4fb1-acfd-9162a02be42b",
"results": [
{
"resource": {
"id": "XX125",
"kind": "student-management",
"policyVersion": "default"
},
"actions": {
"delete": "EFFECT_DENY",
"read": "EFFECT_DENY"
}
}
]
}
The expected response is action read
should be as EFFECT_ALLOW
Please explain why I'm getting EFFECT_DENY instead of EFFECT_ALLOWoguzhan
12/17/2022, 4:15 PMapiVersion: api.cerbos.dev/v1
resourcePolicy:
version: default
resource: student-management
We will consider to make resource policy optional in a future release.Mohan Prasath
12/19/2022, 4:39 AMoguzhan
12/19/2022, 8:33 AMcerbosctl
to do that, specifically cerbosctl put
command.
https://docs.cerbos.dev/cerbos/latest/cli/cerbosctl.html#put
Like this;
cerbosctl --server=localhost:3593 --username=user --password=password --plaintext put ~/path/to/resource_policy.yaml
Mohan Prasath
12/19/2022, 8:37 AMoguzhan
12/19/2022, 8:39 AMPOST /admin/policy
) API endpoint to add every type policy, including resource policies.Mohan Prasath
12/19/2022, 8:41 AMoguzhan
12/19/2022, 8:50 AMcurl -X POST <http://127.0.0.1:3592/admin/policy> -u cerbos:cerbosAdmin -H 'Content-Type: application/json' -d '{"policies":[{"apiVersion":"api.cerbos.dev/v1","resourcePolicy":{"version":"default","resource":"student-management"}}]}'
cerbos
and cerbosAdmin
being the Cerbos AdminAPI username and password, respectively.Mohan Prasath
12/19/2022, 8:52 AM