<@U04UQ68083H> Is there a way in Keto to create re...
# ory-copilot
b
@chilly-king-10285 Is there a way in Keto to create regular expression based rules for an object?
c
A message from kapa.ai
Yes, in Ory Keto, you can create regular expression-based rules for an object. This is demonstrated in the
keto_engine_acp_ory
access rule example. In the "match" section of the rule, a regular expression is used to match the URL of the object. Here is the example:
Copy code
json {   "id": "some-id",   "upstream": {     "url": "<http://my-backend-service>"   },   "match": {     "url": "<http://my-app/api/users/<[0-9]+>/<[a-zA-Z]+>>",     "methods": [       "GET"     ]   },   "authenticators": [     {       "handler": "anonymous"     }   ],   "authorizer": {     "handler": "keto_engine_acp_ory",     "config": {       "required_action": "my:action:$1",       "required_resource": "my:resource:$2:foo:$1",       "subject": "{{ .Extra.email }}",       "flavor": "exact"     }   },   "mutators": [     {       "handler": "noop"     }   ] }
In this example, the "url" in the "match" section is a regular expression that matches URLs of the form
<http://my-app/api/users/<[0-9]+>/<[a-zA-Z]+>>
. This means it will match any URL that starts with
<http://my-app/api/users/>
, followed by one or more digits, a slash, and one or more letters. You can modify this regular expression to match the specific pattern you need for your object. [Source](https://www.ory.sh/docs/oathkeeper/pipeline/authz#keto_engine_acp_ory-access-rule-example)
b
@chilly-king-10285 Can you provide an example of standalone keto rule with regular expressions for object and not tied to OathKeeper?
c
A message from kapa.ai
I'm sorry, but the provided knowledge sources do not contain an example of a standalone Ory Keto rule with regular expressions for an object that is not tied to Ory Oathkeeper. Ory Keto is primarily used for access control decisions and does not inherently support regular expressions in its policies. It's Ory Oathkeeper that supports regular expressions for matching URLs in its rules. For more detailed information about Ory Keto and its usage, you may want to refer to the [official Ory Keto documentation](https://www.ory.sh/keto/docs/).