Skip to content

Commit 736bf73

Browse files
authored
Merge pull request #143 from biscuit-auth/reject-if
Specification for `reject if`
2 parents cb19032 + c1568d4 commit 736bf73

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

SPECIFICATIONS.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ set inclusion.
163163
The logic language is described by the following EBNF grammar:
164164

165165
```
166-
<origin_clause> ::= <sp>? "trusting " <origin_element> <sp>? ("," <sp>? <orgin_element> <sp>?)*
166+
<origin_clause> ::= <sp>? "trusting " <origin_element> <sp>? ("," <sp>? <origin_element> <sp>?)*
167167
<origin_element> ::= "authority" | "previous" | <signature_alg> "/" <bytes>
168168
<signature_alg> ::= "ed25519"
169169
@@ -291,23 +291,27 @@ To validate an operation, all of a token's checks must succeed.
291291

292292
One block can contain one or more checks.
293293

294-
Their text representation is `check if` or `check all` followed by the body of the query.
294+
Their text representation is `check if`, `check all` or `reject if` followed by the body of the query.
295295
There can be multiple queries inside of a check, it will succeed if any of them
296-
succeeds. They are separated by a `or` token.
296+
succeeds (in the case of `reject if`, the check will fail if any query matches). They are separated by a `or` token.
297297

298298
- a `check if` query succeeds if it finds one set of facts that matches the body and expressions
299299
- a `check all` query succeeds if all the sets of facts that match the body also succeed the expression.
300-
`check all` can only be used starting from block version 4
300+
- a `reject if` query succeeds if no set of facts matches the body and expressions
301+
302+
`check all` can only be used starting from block version 4.
303+
`reject if` can only be used starting from block version 5.
301304

302305
Here are some examples of writing checks:
303306

304307
#### Basic token
305308

306309
This first token defines a list of authority facts giving `read` and `write`
307-
rights on `file1`, `read` on `file2`. The first caveat checks that the operation
310+
rights on `file1`, `read` on `file2`. The first check ensures that the operation
308311
is `read` (and will not allow any other `operation` fact), and then that we have
309-
the `read` right over the resource.
310-
The second caveat checks that the resource is `file1`.
312+
the `read` right over the resource.
313+
The second check ensures that the resource is either `file1` or `file2`.
314+
The third check ensures that the resource is not `file1`.
311315

312316
```
313317
authority:
@@ -323,20 +327,24 @@ check if
323327
----------
324328
Block 2:
325329
check if
326-
resource("file1") // restrict to file1 resource
330+
resource("file1")
331+
or resource("file2") // restrict to file1 or file2
332+
----------
333+
Block 3:
334+
reject if
335+
resource("file1") // forbid using the token on file1
327336
```
328337

329338
The verifier side provides the `resource` and `operation` facts with information
330339
from the request.
331340

332-
If the verifier provided the facts `resource("file2")` and
341+
If the verifier provided the facts `resource("file1")` and
333342
`operation("read")`, the rule application of the first check would see
334-
`resource("file2"), operation("read"), right("file2", "read")`
335-
with `X = "file2"`, so it would succeed, but the second check would fail
336-
because it expects `resource("file1")`.
343+
`resource("file1"), operation("read"), right("file1", "read")`
344+
with `X = "file1"`, so it would succeed, the second check would also succeed because it expects `resource("file1")` or `resource("file2")`. The third check would then fail because it would match on `resource("file1")`.
337345

338-
If the verifier provided the facts `resource("file1")` and
339-
`operation("read")`, both checks would succeed.
346+
If the verifier provided the facts `resource("file2")` and
347+
`operation("read")`, all checks would succeed.
340348

341349
#### Broad authority rules
342350

@@ -661,7 +669,7 @@ each block must carry its own version.
661669
when possible, especially for biscuit versions that are only additive in terms of features.
662670

663671
- The lowest supported biscuit version is `3`;
664-
- The highest supported biscuit version is `4`;
672+
- The highest supported biscuit version is `5`;
665673

666674
# Version 2
667675

0 commit comments

Comments
 (0)