Skip to content

Commit e97de78

Browse files
committed
drop minimize until its determined its actually helpful
1 parent 6745dd7 commit e97de78

File tree

2 files changed

+0
-87
lines changed

2 files changed

+0
-87
lines changed

docs/specification/functions.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,38 +39,3 @@ validate_scope(
3939
scopeOrRule string,
4040
) error
4141
```
42-
43-
## Minimize
44-
Minimize will attempt to reduce the number of scopes or rules by following a few checks.
45-
During this process each scope or rule is also validated using the validate_scope
46-
specification exiting early if any invalid scopes are found. This allows you to
47-
call minimize in place of validation if you're end goal is the scopes or rules
48-
and not just checking input is valid.
49-
50-
### Checks
51-
52-
1. Merge identical scopes
53-
1. `["blog/read", "blog/read"]` to `["blog/read"]`
54-
1. Merge into arrays
55-
1. `["blog/read", "blog/create"]` to `["blog/read|create"]`
56-
1. Reduce by wildcards and super wildcards
57-
1. `["blog/read", "blog/*"]` to `["blog/*"]`
58-
1. `["blog/tech/read", "blog/tech/write", "blog/**"]` to `["blog/**"]`
59-
1. Remove allow rules that match a deny rule
60-
1. `["allow/blog/read", "deny/blog/*"]` to `["deny/blog/*"]`
61-
62-
There are some conditions we do not merge.
63-
64-
1. Guessing wildcards:
65-
1. Given you have read and write as the only two valid options: `["a/read", "a/write"]`
66-
1. We will not merge this to `["a/*"]` as we would not know these are the only two options.
67-
1. Additionally, using `*` implies everything no and in the future.
68-
1. Where as `read|write` implies just these two and if we add more, do not add them.
69-
70-
```py title="Minimize"
71-
minimize(
72-
# Given scopes or rules to minimize.
73-
# It is expected that it is all scopes or all rules, otherwise it will fail.
74-
scopeOrRules: []string,
75-
) []string and error
76-
```

scenarios.json

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -244,58 +244,6 @@
244244
"error": "scopie-106: scope was empty"
245245
}
246246
],
247-
"minimizeTests": [
248-
{
249-
"id": "duplicate scope",
250-
"scopesOrRules": ["blog/read", "blog/read"],
251-
"result": ["blog/read"]
252-
},
253-
{
254-
"id": "merge array",
255-
"scopesOrRules": ["blog/create", "blog/read"],
256-
"result": ["blog/create|read"]
257-
},
258-
{
259-
"id": "append to array",
260-
"scopesOrRules": ["blog/create", "blog/read|update"],
261-
"result": ["blog/create|read|update"]
262-
},
263-
{
264-
"id": "wildcard reduction",
265-
"scopesOrRules": ["blog/create", "blog/read", "blog/*"],
266-
"result": ["blog/*"]
267-
},
268-
{
269-
"id": "super wildcard reduction",
270-
"scopesOrRules": ["blog/create", "blog/read", "blog/**"],
271-
"result": ["blog/**"]
272-
},
273-
{
274-
"id": "super wildcard reduction at two levels",
275-
"scopesOrRules": ["blog/tech/read", "blog/tech/write", "blog/**"],
276-
"result": ["blog/**"]
277-
},
278-
{
279-
"id": "remove allow if it exactly matches a deny",
280-
"scopesOrRules": ["allow/blog/read", "deny/blog/read"],
281-
"result": ["deny/blog/read"]
282-
},
283-
{
284-
"id": "remove allow if it is under a deny",
285-
"scopesOrRules": ["allow/blog/tech/read", "deny/blog/**"],
286-
"result": ["deny/blog/**"]
287-
},
288-
{
289-
"id": "deep nested scope is still array swapped",
290-
"scopesOrRules": ["a/b/c/d/e", "a/f/c/d/e"],
291-
"result": ["a/b/c/d/e", "a/f/c/d/e"]
292-
},
293-
{
294-
"id": "deep nested scopes with top and bottom level difference is not minimized",
295-
"scopesOrRules": ["a/b/c/d/e", "a/f/c/d/g"],
296-
"result": ["a/b/c/d/e", "a/f/c/d/g"]
297-
}
298-
],
299247
"benchmarks": [
300248
{
301249
"id": "allow,1actor,1rule,1block1length",

0 commit comments

Comments
 (0)