tba-concrete-authorization-scope-set-matcher 0.4.0.dev2__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.
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: tba-concrete-authorization-scope-set-matcher
3
+ Version: 0.4.0.dev2
4
+ Summary:
5
+ Requires-Python: >=3.10,<3.15
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Programming Language :: Python :: 3.10
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Programming Language :: Python :: 3.13
11
+ Classifier: Programming Language :: Python :: 3.14
12
+ Requires-Dist: tba-bases-authorization-policy (==0.4.0.dev2)
13
+ Requires-Dist: tba-contracts-identity (==0.4.0.dev2)
@@ -0,0 +1,10 @@
1
+ [project]
2
+ name="tba-concrete-authorization-scope-set-matcher"
3
+ version="0.4.0.dev2"
4
+ requires-python=">=3.10,<3.15"
5
+ dependencies=["tba-contracts-identity==0.4.0.dev2","tba-bases-authorization-policy==0.4.0.dev2"]
6
+ [build-system]
7
+ requires=["poetry-core>=1.0.0"]
8
+ build-backend="poetry.core.masonry.api"
9
+ [tool.poetry]
10
+ packages=[{include="tba_concrete_authorization_scope_set_matcher",from="src"}]
@@ -0,0 +1,23 @@
1
+ from tba_bases_authorization_policy import ScopeMatcherBase
2
+ from tba_contracts_identity.authorization_scopes import (
3
+ ScopeMatchRequest,
4
+ ScopeMatchResult,
5
+ )
6
+
7
+
8
+ class ScopeSetMatcher(ScopeMatcherBase):
9
+ def match(self, request: ScopeMatchRequest, /) -> ScopeMatchResult:
10
+ granted = set(request.granted)
11
+ required = set(request.required)
12
+ if request.mode == "any":
13
+ allowed = not required or bool(granted & required)
14
+ missing = () if allowed else tuple(sorted(required))
15
+ else:
16
+ missing = tuple(sorted(required - granted))
17
+ allowed = not missing
18
+ return ScopeMatchResult(
19
+ allowed, tuple(sorted(granted)), tuple(sorted(required)), missing
20
+ )
21
+
22
+
23
+ __all__ = ["ScopeSetMatcher"]