tba-concrete-authorization-policy-combiner-default 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.
- tba_concrete_authorization_policy_combiner_default-0.4.0.dev2/PKG-INFO +35 -0
- tba_concrete_authorization_policy_combiner_default-0.4.0.dev2/README.md +5 -0
- tba_concrete_authorization_policy_combiner_default-0.4.0.dev2/pyproject.toml +41 -0
- tba_concrete_authorization_policy_combiner_default-0.4.0.dev2/src/tba_concrete_authorization_policy_combiner_default/__init__.py +31 -0
- tba_concrete_authorization_policy_combiner_default-0.4.0.dev2/src/tba_concrete_authorization_policy_combiner_default/py.typed +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tba-concrete-authorization-policy-combiner-default
|
|
3
|
+
Version: 0.4.0.dev2
|
|
4
|
+
Summary: Default concrete authorization policy combiner.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Keywords: tigrbl,identity,auth,security
|
|
7
|
+
Requires-Python: >=3.10,<3.15
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Classifier: Topic :: Security
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Dist: tba-bases-authorization-policy (==0.4.0.dev2)
|
|
22
|
+
Requires-Dist: tba-contracts-identity (==0.4.0.dev2)
|
|
23
|
+
Project-URL: Homepage, https://github.com/tigrbl/tigrbl_auth
|
|
24
|
+
Project-URL: PyPI, https://pypi.org/project/tba-concrete-authorization-policy-combiner-default/
|
|
25
|
+
Project-URL: Repository, https://github.com/tigrbl/tigrbl_auth
|
|
26
|
+
Project-URL: Source, https://github.com/tigrbl/tigrbl_auth/tree/master/pkgs/10-concrete/tba-concrete-authorization-policy-combiner-default
|
|
27
|
+
Project-URL: SSOT, https://github.com/tigrbl/tigrbl_auth/blob/master/.ssot/registry.json
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# tba-concrete-authorization-policy-combiner-default
|
|
31
|
+
|
|
32
|
+
Default concrete authorization policy combiner.
|
|
33
|
+
|
|
34
|
+
Import root: `tba_concrete_authorization_policy_combiner_default`.
|
|
35
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "tba-concrete-authorization-policy-combiner-default"
|
|
3
|
+
version = "0.4.0.dev2"
|
|
4
|
+
description = "Default concrete authorization policy combiner."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10,<3.15"
|
|
7
|
+
license = "Apache-2.0"
|
|
8
|
+
keywords = ["tigrbl", "identity", "auth", "security"]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 3 - Alpha",
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"License :: OSI Approved :: Apache Software License",
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Programming Language :: Python :: 3.10",
|
|
15
|
+
"Programming Language :: Python :: 3.11",
|
|
16
|
+
"Programming Language :: Python :: 3.12",
|
|
17
|
+
"Programming Language :: Python :: 3.13",
|
|
18
|
+
"Programming Language :: Python :: 3.14",
|
|
19
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
20
|
+
"Typing :: Typed",
|
|
21
|
+
"Topic :: Security",
|
|
22
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"tba-bases-authorization-policy==0.4.0.dev2",
|
|
26
|
+
"tba-contracts-identity==0.4.0.dev2",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/tigrbl/tigrbl_auth"
|
|
31
|
+
Repository = "https://github.com/tigrbl/tigrbl_auth"
|
|
32
|
+
Source = "https://github.com/tigrbl/tigrbl_auth/tree/master/pkgs/10-concrete/tba-concrete-authorization-policy-combiner-default"
|
|
33
|
+
SSOT = "https://github.com/tigrbl/tigrbl_auth/blob/master/.ssot/registry.json"
|
|
34
|
+
PyPI = "https://pypi.org/project/tba-concrete-authorization-policy-combiner-default/"
|
|
35
|
+
|
|
36
|
+
[build-system]
|
|
37
|
+
requires = ["poetry-core>=1.0.0"]
|
|
38
|
+
build-backend = "poetry.core.masonry.api"
|
|
39
|
+
|
|
40
|
+
[tool.poetry]
|
|
41
|
+
packages = [{ include = "tba_concrete_authorization_policy_combiner_default", from = "src" }]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Concrete policy combining algorithms."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from tba_bases_authorization_policy import PolicyCombinerBase
|
|
6
|
+
from tba_contracts_identity.policy import CombiningAlgorithmKind, PolicyCombineRequest, PolicyDecision
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DefaultPolicyCombiner(PolicyCombinerBase):
|
|
10
|
+
def combine(self, request: PolicyCombineRequest, /) -> PolicyDecision:
|
|
11
|
+
if not request.decisions:
|
|
12
|
+
return PolicyDecision(False, "no policy decision", ())
|
|
13
|
+
if request.algorithm is CombiningAlgorithmKind.FIRST_APPLICABLE:
|
|
14
|
+
return request.decisions[0]
|
|
15
|
+
if request.algorithm is CombiningAlgorithmKind.PERMIT_OVERRIDES:
|
|
16
|
+
for decision in request.decisions:
|
|
17
|
+
if decision.allowed:
|
|
18
|
+
return decision
|
|
19
|
+
return request.decisions[0]
|
|
20
|
+
if request.algorithm is CombiningAlgorithmKind.ONLY_ONE_APPLICABLE:
|
|
21
|
+
applicable = [decision for decision in request.decisions if decision.matched]
|
|
22
|
+
if len(applicable) == 1:
|
|
23
|
+
return applicable[0]
|
|
24
|
+
return PolicyDecision(False, "only-one-applicable policy count mismatch", ())
|
|
25
|
+
for decision in request.decisions:
|
|
26
|
+
if not decision.allowed:
|
|
27
|
+
return decision
|
|
28
|
+
return request.decisions[0]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
__all__ = ["DefaultPolicyCombiner"]
|