I'm using OPA to write an access policy to a microservice, and I'm now tackling the problem of matching an URL containing a path param.
The URL follows the pattern: /v1/users/{uuid}
I came up with the following regex which matches /v1/users/ followed by a valid UUID: ^/v1/users/[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$
When testing it against /v1/users/29fe7f14-f04b-4607-9ece-9bd0525f7b38 on an online regex tester it succesfully matches.
However, it isn't matching inside the policy:
is_accessing_user_resource if {
re_match(
"^/v1/users/[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$",
input.path,
)
}
I'm testing it with the following input.json
{
"body": null,
"claims": {},
"method": "GET",
"path": "/v1/users/29fe7f14-f04b-4607-9ece-9bd0525f7b38"
}
Is there any adaptation needed when using regex in rego?