https://cerbos.dev logo
#community
Title
# community
v

Viet Au

08/16/2022, 10:20 AM
Hi, when talking directly to the Cerbos gRPC service, how do I represent the attributes for a principal and for a resource in JSON? I need this for testing the gRPC in Postman and K6. Trying to do similar to this example in the playground https://play.cerbos.dev/p/LXjgi62fb63c1QypYuZhsyRK3cTMcRx5 This is what I have but it does not work.
{
"requestId": "123123",
"version": "default",
"principal": {
"id": "<mailto:email@email.com|email@email.com>",
"roles": [
"user"
],
"attr": [
{
"key":"salesreps",
"value": {
"kind": {
"listValue": ["1","2"]
}
}
}
]
},
"resources": [
{
"resource": {
"kind": "customer",
"version": "default",
"id": "12345",
"scope": "teamb",
"attr": [
{
"key":"salesrep",
"value": {
"kind": {
"stringValue": "2"
}
}
}
]
},
"actions": ["VIEW"]
}
]
}
a

Alex Olivier (Cerbos)

08/16/2022, 10:21 AM
The attrbuite field should just be a map eg
Copy code
"principal": {
    "id": "alice",
    "roles": ["employee"],
    "attr": {
      "department": "accounting",
      "geography": "GB",
      "team": "design"
    }
  },
v

Viet Au

08/16/2022, 10:24 AM
ok let me try grpcurl, it could be a postman issue but it doesn't like it when I did this. It expects the attr to be an array.
a

Alex Olivier (Cerbos)

08/16/2022, 10:25 AM
Odd - let me us know how you get on
v

Viet Au

08/16/2022, 10:26 AM
will do
a

Alex Olivier (Cerbos)

08/16/2022, 10:26 AM
The protobuf type is
map<string, google.protobuf.Value>
v

Viet Au

08/16/2022, 10:52 AM
grpc curl works, must be how postman did reflection on the grpc end point.
4 Views