-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
14 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ Here is an illustrative example: | |
"cmd": "/blog/post/create", | ||
"pol": [ | ||
["==", ".status", "draft"], | ||
["every", ".reviewer", ["match", ".email", "*@example.com"]], | ||
["every", ".reviewer", ["like", ".email", "*@example.com"]], | ||
["some", ".tags", | ||
["or", | ||
["==", ".", "news"], | ||
|
@@ -136,7 +136,7 @@ Below is a formal syntax for the UCAN Policy Language given in [ABNF] (for DAG-J | |
policy = "[" *1(statement *("," statement)) "]" | ||
statement = equality | ||
/ inequality | ||
/ match | ||
/ like | ||
/ connective | ||
/ quantifier | ||
|
@@ -157,7 +157,7 @@ inequality = "[" DQUOTE ">" DQUOTE "," selector "," number "]" ; Numeric great | |
/ "[" DQUOTE "<" DQUOTE "," selector "," number "]" ; Numeric lesser-than | ||
/ "[" DQUOTE "<=" DQUOTE "," selector "," number "]" ; Numeric lesser-than-or-equal | ||
match = "[" DQUOTE "match" DQUOTE "," selector "," pattern "]" ; String wildcard matching | ||
like = "[" DQUOTE "like" DQUOTE "," selector "," pattern "]" ; String wildcard matching | ||
;; SELECTORS | ||
|
@@ -191,9 +191,9 @@ Numeric inequalities MUST be agnostic to numeric type. In other words, the decim | |
|
||
## Glob Matching | ||
|
||
| Operator | Argument(s) | Example | | ||
|----------|---------------------|-------------------------------------| | ||
| `match` | `Selector, Pattern` | `["==", ".email", "*@example.com"]` | | ||
| Operator | Argument(s) | Example | | ||
|----------|---------------------|---------------------------------------| | ||
| `like` | `Selector, Pattern` | `["like", ".email", "*@example.com"]` | | ||
|
||
Glob patterns MUST only include one specicial character: `*` ("wildcard"). There is no single character matcher. As many `*`s as desired MAY be used. Non-wildcard `*`-literals MUST be escaped (`"\*"`). Attempting to match on a non-string MUST return false and MUST NOT throw an exception. | ||
|
||
|
@@ -455,7 +455,7 @@ Below is a step-by-step evaluation example: | |
"cmd": "/msg", | ||
"pol": [ | ||
["==", ".from", "[email protected]"], | ||
["some", ".to", ["match", ".", "*@example.com"]] | ||
["some", ".to", ["like", ".", "*@example.com"]] | ||
], | ||
// ... | ||
} | ||
|
@@ -464,27 +464,27 @@ Below is a step-by-step evaluation example: | |
``` js | ||
[ // Extract policy | ||
["==", ".from", "[email protected]"], | ||
["some", ".to", ["match", ".", "*@example.com"]] | ||
["some", ".to", ["like", ".", "*@example.com"]] | ||
] | ||
|
||
[ // Resolve selectors | ||
["==", "[email protected]", "[email protected]"], | ||
["some", ["[email protected]", "[email protected]"], ["match", ".", "*@example.com"]] | ||
["some", ["[email protected]", "[email protected]"], ["like", ".", "*@example.com"]] | ||
] | ||
|
||
[ // Expand quantifier | ||
["==", "[email protected]", "[email protected]"], | ||
["or", [ | ||
["match", "[email protected]", "*@example.com"] | ||
["match", "[email protected]", "*@example.com"]] | ||
["like", "[email protected]", "*@example.com"] | ||
["like", "[email protected]", "*@example.com"]] | ||
] | ||
] | ||
|
||
[ // Evaluate first predicate | ||
true, | ||
["or", [ | ||
["match", "[email protected]", "*@example.com"] | ||
["match", "[email protected]", "*@example.com"]]] | ||
["like", "[email protected]", "*@example.com"] | ||
["like", "[email protected]", "*@example.com"]]] | ||
] | ||
|
||
[ // Evaluate second predicate's children | ||
|
@@ -512,7 +512,7 @@ Note that this also applies to arrays and objects. For example, the `to` array i | |
"cmd": "/email/send", | ||
"pol": [ | ||
["==", ".from", "[email protected]"], | ||
["some", ".to", ["match", ".", "*@example.com"]] | ||
["some", ".to", ["like", ".", "*@example.com"]] | ||
] | ||
// ... | ||
} | ||
|