Peter McClonski
02/01/2025, 5:51 PMSam Lock (Cerbos)
02/01/2025, 6:27 PMPeter McClonski
02/01/2025, 6:45 PMSam Lock (Cerbos)
02/01/2025, 8:35 PM---
apiVersion: api.cerbos.dev/v1
resourcePolicy:
resource: social_security_no
version: default
rules:
- actions:
- validate
roles: ["*"]
effect: EFFECT_ALLOW
condition:
match:
expr: R.id.matches("^[0-9]{3}-[0-9]{2}-[0-9]{4}$")
The query plan aspect I'm less sure about as I'm not sure what it would currently output, but I can have a tinker next week! I'd expect it to require mapping to some database specific match
query or the like.Sam Lock (Cerbos)
02/03/2025, 7:58 AMmatch
clause (for the simple case); here's the response:
{
"requestId": "test",
"action": "validate",
"resourceKind": "social_security_no",
"policyVersion": "default",
"filter": {
"kind": "KIND_CONDITIONAL",
"condition": {
"expression": {
"operator": "matches",
"operands": [
{
"variable": "request.resource.id"
},
{
"value": "^[0-9]{3}-[0-9]{2}-[0-9]{4}$"
}
]
}
}
},
"cerbosCallId": "01JK5CYRDBAT29HVAKB86QKN4Z"
}
So, as originally thought, it's a matter of translating the match
operator to the query language of your choice.Peter McClonski
02/03/2025, 2:28 PM