policy-pattern 0.2.4__tar.gz → 0.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/PKG-INFO +39 -2
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/README.md +38 -1
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/pyproject.toml +1 -1
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/pyproject.toml.orig +1 -1
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/LICENSE.md +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/__init__.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/adapters/__init__.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/adapters/memory.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/errors/__init__.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/errors/base_error.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/errors/evaluation_error.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/errors/identifier_error.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/errors/model_validation_error.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/errors/mutation_error.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/errors/relation_error.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/errors/unknown_name_error.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/errors/unknown_type_error.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/evaluator.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/__init__.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/_schema_validation.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/compiled_model.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/direct_subject.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/identifier.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/model.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/mutation.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/object_reference.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/operators.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/reference.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/relation.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/subject.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/subject_set.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/tuple.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/tuple_to_userset.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/models/type.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/ports/__init__.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/ports/tuple_store.py +0 -0
- {policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: policy-pattern
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: A minimal, embeddable ReBAC authorization engine for Python, inspired by Google Zanzibar.
|
|
5
5
|
Keywords: python,authorization,access-control,rebac,zanzibar,security
|
|
6
6
|
Author: Guillem Pozo Sebastián
|
|
@@ -77,7 +77,27 @@ See [Architecture § Scope](docs/architecture.md#scope) for what's planned (v1.x
|
|
|
77
77
|
## Example
|
|
78
78
|
|
|
79
79
|
```python
|
|
80
|
+
from policy_pattern.adapters.memory import MemoryTupleStore
|
|
81
|
+
from policy_pattern.evaluator import Evaluator
|
|
82
|
+
from policy_pattern.models import (
|
|
83
|
+
DirectSubject,
|
|
84
|
+
Model,
|
|
85
|
+
Mutation,
|
|
86
|
+
ObjectReference,
|
|
87
|
+
Reference,
|
|
88
|
+
Relation,
|
|
89
|
+
Tuple,
|
|
90
|
+
TupleToUserset,
|
|
91
|
+
Type,
|
|
92
|
+
Union,
|
|
93
|
+
)
|
|
94
|
+
|
|
80
95
|
model = Model()
|
|
96
|
+
model.types["folder"] = Type(
|
|
97
|
+
name="folder",
|
|
98
|
+
relations={"owner": Relation(allowed_subject_types=("user",))},
|
|
99
|
+
permissions={"viewer": Reference(name="owner")},
|
|
100
|
+
)
|
|
81
101
|
model.types["document"] = Type(
|
|
82
102
|
name="document",
|
|
83
103
|
relations={
|
|
@@ -90,8 +110,25 @@ model.types["document"] = Type(
|
|
|
90
110
|
)
|
|
91
111
|
compiled = model.compile()
|
|
92
112
|
|
|
113
|
+
store = MemoryTupleStore()
|
|
114
|
+
alice = DirectSubject(object=ObjectReference(type="user", id="alice"))
|
|
115
|
+
engineering = ObjectReference(type="folder", id="engineering")
|
|
116
|
+
document_42 = ObjectReference(type="document", id="42")
|
|
117
|
+
|
|
118
|
+
store.write_tuples(
|
|
119
|
+
Mutation(
|
|
120
|
+
additions=frozenset(
|
|
121
|
+
{
|
|
122
|
+
Tuple(subject=alice, relation="owner", object=engineering),
|
|
123
|
+
Tuple(subject=DirectSubject(object=engineering), relation="parent", object=document_42),
|
|
124
|
+
}
|
|
125
|
+
),
|
|
126
|
+
deletions=frozenset(),
|
|
127
|
+
)
|
|
128
|
+
)
|
|
129
|
+
|
|
93
130
|
evaluator = Evaluator(model=compiled, store=store)
|
|
94
|
-
evaluator.check(alice, "viewer", document_42)
|
|
131
|
+
evaluator.check(alice, "viewer", document_42) # True — alice owns the parent folder
|
|
95
132
|
```
|
|
96
133
|
|
|
97
134
|
`viewer` here means "the document's own owner, or the owner of whatever folder it lives in" — a document under
|
|
@@ -52,7 +52,27 @@ See [Architecture § Scope](docs/architecture.md#scope) for what's planned (v1.x
|
|
|
52
52
|
## Example
|
|
53
53
|
|
|
54
54
|
```python
|
|
55
|
+
from policy_pattern.adapters.memory import MemoryTupleStore
|
|
56
|
+
from policy_pattern.evaluator import Evaluator
|
|
57
|
+
from policy_pattern.models import (
|
|
58
|
+
DirectSubject,
|
|
59
|
+
Model,
|
|
60
|
+
Mutation,
|
|
61
|
+
ObjectReference,
|
|
62
|
+
Reference,
|
|
63
|
+
Relation,
|
|
64
|
+
Tuple,
|
|
65
|
+
TupleToUserset,
|
|
66
|
+
Type,
|
|
67
|
+
Union,
|
|
68
|
+
)
|
|
69
|
+
|
|
55
70
|
model = Model()
|
|
71
|
+
model.types["folder"] = Type(
|
|
72
|
+
name="folder",
|
|
73
|
+
relations={"owner": Relation(allowed_subject_types=("user",))},
|
|
74
|
+
permissions={"viewer": Reference(name="owner")},
|
|
75
|
+
)
|
|
56
76
|
model.types["document"] = Type(
|
|
57
77
|
name="document",
|
|
58
78
|
relations={
|
|
@@ -65,8 +85,25 @@ model.types["document"] = Type(
|
|
|
65
85
|
)
|
|
66
86
|
compiled = model.compile()
|
|
67
87
|
|
|
88
|
+
store = MemoryTupleStore()
|
|
89
|
+
alice = DirectSubject(object=ObjectReference(type="user", id="alice"))
|
|
90
|
+
engineering = ObjectReference(type="folder", id="engineering")
|
|
91
|
+
document_42 = ObjectReference(type="document", id="42")
|
|
92
|
+
|
|
93
|
+
store.write_tuples(
|
|
94
|
+
Mutation(
|
|
95
|
+
additions=frozenset(
|
|
96
|
+
{
|
|
97
|
+
Tuple(subject=alice, relation="owner", object=engineering),
|
|
98
|
+
Tuple(subject=DirectSubject(object=engineering), relation="parent", object=document_42),
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
deletions=frozenset(),
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
|
|
68
105
|
evaluator = Evaluator(model=compiled, store=store)
|
|
69
|
-
evaluator.check(alice, "viewer", document_42)
|
|
106
|
+
evaluator.check(alice, "viewer", document_42) # True — alice owns the parent folder
|
|
70
107
|
```
|
|
71
108
|
|
|
72
109
|
`viewer` here means "the document's own owner, or the owner of whatever folder it lives in" — a document under
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{policy_pattern-0.2.4 → policy_pattern-0.2.5}/policy_pattern/errors/model_validation_error.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|