Skip to content

Commit 119caf7

Browse files
committed
update samples
- Use sets in closures sample eclipse-biscuit/biscuit-rust#289 - Add a case for check all with no matches eclipse-biscuit/biscuit-rust#294 - Add missing case in heterogeneous equals sample eclipse-biscuit/biscuit-rust#309
1 parent 10c8d5b commit 119caf7

File tree

3 files changed

+103
-7
lines changed

3 files changed

+103
-7
lines changed

samples/current/README.md

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,49 @@ World {
21082108
}
21092109
```
21102110

2111+
result: `Err(FailedLogic(Unauthorized { policy: Allow(0), checks: [Block(FailedBlockCheck { block_id: 0, check_id: 0, rule: "check all operation($op), allowed_operations($allowed), $allowed.contains($op)" })] }))`
2112+
### validation for "no matches"
2113+
2114+
authorizer code:
2115+
```
2116+
allow if true;
2117+
```
2118+
2119+
revocation ids:
2120+
- `c456817012e1d523c6d145b6d6a3475d9f7dd4383c535454ff3f745ecf4234984ce09b9dec0551f3d783abe850f826ce43b12f1fd91999a4753a56ecf4c56d0d`
2121+
2122+
authorizer world:
2123+
```
2124+
World {
2125+
facts: [
2126+
Facts {
2127+
origin: {
2128+
Some(
2129+
0,
2130+
),
2131+
},
2132+
facts: [
2133+
"allowed_operations({\"A\", \"B\"})",
2134+
],
2135+
},
2136+
]
2137+
rules: []
2138+
checks: [
2139+
Checks {
2140+
origin: Some(
2141+
0,
2142+
),
2143+
checks: [
2144+
"check all operation($op), allowed_operations($allowed), $allowed.contains($op)",
2145+
],
2146+
},
2147+
]
2148+
policies: [
2149+
"allow if true",
2150+
]
2151+
}
2152+
```
2153+
21112154
result: `Err(FailedLogic(Unauthorized { policy: Allow(0), checks: [Block(FailedBlockCheck { block_id: 0, check_id: 0, rule: "check all operation($op), allowed_operations($allowed), $allowed.contains($op)" })] }))`
21122155

21132156

@@ -2417,6 +2460,7 @@ public keys: []
24172460
block version: 4
24182461

24192462
```
2463+
check if true !== false;
24202464
check if 1 !== 3;
24212465
check if 1 | 2 ^ 3 === 0;
24222466
check if "abcD12x" !== "abcD12";
@@ -2433,7 +2477,7 @@ allow if true;
24332477
```
24342478

24352479
revocation ids:
2436-
- `117fa653744c859561555e6a6f5990e3a8e7817f91b87aa6991b6d64297158b4e884c92d10f49f74c96069df722aa676839b72751ca9d1fe83a7025b591de00b`
2480+
- `9402c07923aa33bc911de80e61f388f5c4533e6b36e45317dc1db1e6bcc7664ed0c1c504d0ca8925208008961d95bbdbc36f6e3d91b3173369cc19ed625e9a0c`
24372481

24382482
authorizer world:
24392483
```
@@ -2451,6 +2495,7 @@ World {
24512495
"check if 1 | 2 ^ 3 === 0",
24522496
"check if 2022-12-04T09:46:41Z !== 2020-12-04T09:46:41Z",
24532497
"check if hex:12abcd !== hex:12ab",
2498+
"check if true !== false",
24542499
"check if {1, 4} !== {1, 2}",
24552500
],
24562501
},
@@ -3011,7 +3056,7 @@ result: `Ok(0)`
30113056

30123057
authorizer code:
30133058
```
3014-
allow if [true].any($p -> [true].all($p -> $p));
3059+
allow if {"true"}.any($p -> {"true"}.all($p -> $p));
30153060
```
30163061

30173062
revocation ids:
@@ -3042,7 +3087,7 @@ World {
30423087
},
30433088
]
30443089
policies: [
3045-
"allow if [true].any($p -> [true].all($p -> $p))",
3090+
"allow if {\"true\"}.any($p -> {\"true\"}.all($p -> $p))",
30463091
]
30473092
}
30483093
```

samples/current/samples.json

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,56 @@
19651965
"revocation_ids": [
19661966
"c456817012e1d523c6d145b6d6a3475d9f7dd4383c535454ff3f745ecf4234984ce09b9dec0551f3d783abe850f826ce43b12f1fd91999a4753a56ecf4c56d0d"
19671967
]
1968+
},
1969+
"no matches": {
1970+
"world": {
1971+
"facts": [
1972+
{
1973+
"origin": [
1974+
0
1975+
],
1976+
"facts": [
1977+
"allowed_operations({\"A\", \"B\"})"
1978+
]
1979+
}
1980+
],
1981+
"rules": [],
1982+
"checks": [
1983+
{
1984+
"origin": 0,
1985+
"checks": [
1986+
"check all operation($op), allowed_operations($allowed), $allowed.contains($op)"
1987+
]
1988+
}
1989+
],
1990+
"policies": [
1991+
"allow if true"
1992+
]
1993+
},
1994+
"result": {
1995+
"Err": {
1996+
"FailedLogic": {
1997+
"Unauthorized": {
1998+
"policy": {
1999+
"Allow": 0
2000+
},
2001+
"checks": [
2002+
{
2003+
"Block": {
2004+
"block_id": 0,
2005+
"check_id": 0,
2006+
"rule": "check all operation($op), allowed_operations($allowed), $allowed.contains($op)"
2007+
}
2008+
}
2009+
]
2010+
}
2011+
}
2012+
}
2013+
},
2014+
"authorizer_code": "allow if true;\n",
2015+
"revocation_ids": [
2016+
"c456817012e1d523c6d145b6d6a3475d9f7dd4383c535454ff3f745ecf4234984ce09b9dec0551f3d783abe850f826ce43b12f1fd91999a4753a56ecf4c56d0d"
2017+
]
19682018
}
19692019
}
19702020
},
@@ -2201,7 +2251,7 @@
22012251
],
22022252
"public_keys": [],
22032253
"external_key": null,
2204-
"code": "check if 1 !== 3;\ncheck if 1 | 2 ^ 3 === 0;\ncheck if \"abcD12x\" !== \"abcD12\";\ncheck if 2022-12-04T09:46:41Z !== 2020-12-04T09:46:41Z;\ncheck if hex:12abcd !== hex:12ab;\ncheck if {1, 4} !== {1, 2};\n",
2254+
"code": "check if true !== false;\ncheck if 1 !== 3;\ncheck if 1 | 2 ^ 3 === 0;\ncheck if \"abcD12x\" !== \"abcD12\";\ncheck if 2022-12-04T09:46:41Z !== 2020-12-04T09:46:41Z;\ncheck if hex:12abcd !== hex:12ab;\ncheck if {1, 4} !== {1, 2};\n",
22052255
"version": 4
22062256
}
22072257
],
@@ -2219,6 +2269,7 @@
22192269
"check if 1 | 2 ^ 3 === 0",
22202270
"check if 2022-12-04T09:46:41Z !== 2020-12-04T09:46:41Z",
22212271
"check if hex:12abcd !== hex:12ab",
2272+
"check if true !== false",
22222273
"check if {1, 4} !== {1, 2}"
22232274
]
22242275
}
@@ -2232,7 +2283,7 @@
22322283
},
22332284
"authorizer_code": "allow if true;\n",
22342285
"revocation_ids": [
2235-
"117fa653744c859561555e6a6f5990e3a8e7817f91b87aa6991b6d64297158b4e884c92d10f49f74c96069df722aa676839b72751ca9d1fe83a7025b591de00b"
2286+
"9402c07923aa33bc911de80e61f388f5c4533e6b36e45317dc1db1e6bcc7664ed0c1c504d0ca8925208008961d95bbdbc36f6e3d91b3173369cc19ed625e9a0c"
22362287
]
22372288
}
22382289
}
@@ -2800,15 +2851,15 @@
28002851
}
28012852
],
28022853
"policies": [
2803-
"allow if [true].any($p -> [true].all($p -> $p))"
2854+
"allow if {\"true\"}.any($p -> {\"true\"}.all($p -> $p))"
28042855
]
28052856
},
28062857
"result": {
28072858
"Err": {
28082859
"Execution": "ShadowedVariable"
28092860
}
28102861
},
2811-
"authorizer_code": "allow if [true].any($p -> [true].all($p -> $p));\n",
2862+
"authorizer_code": "allow if {\"true\"}.any($p -> {\"true\"}.all($p -> $p));\n",
28122863
"revocation_ids": [
28132864
"2cd348b6df5f08b900903fd8d3fbea0bb89b665c331a2aa2131e0b8ecb38b3550275d4ccd8db35da6c4433eed1d456cfb761e3fcc7845894d891e986ca044b02"
28142865
]
28 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)