tba-concrete-claim-authorization-context 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_claim_authorization_context-0.4.0.dev2/PKG-INFO +13 -0
- tba_concrete_claim_authorization_context-0.4.0.dev2/pyproject.toml +16 -0
- tba_concrete_claim_authorization_context-0.4.0.dev2/src/tba_concrete_claim_authorization_context/__init__.py +37 -0
- tba_concrete_claim_authorization_context-0.4.0.dev2/src/tba_concrete_claim_authorization_context/py.typed +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tba-concrete-claim-authorization-context
|
|
3
|
+
Version: 0.4.0.dev2
|
|
4
|
+
Summary: Standalone draft authorization context (actx) claim implementation.
|
|
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-claim (==0.4.0.dev2)
|
|
13
|
+
Requires-Dist: tba-primitives-identity (==0.4.0.dev2)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "tba-concrete-claim-authorization-context"
|
|
3
|
+
version = "0.4.0.dev2"
|
|
4
|
+
description = "Standalone draft authorization context (actx) claim implementation."
|
|
5
|
+
requires-python = ">=3.10,<3.15"
|
|
6
|
+
dependencies = [
|
|
7
|
+
"tba-primitives-identity==0.4.0.dev2",
|
|
8
|
+
"tba-bases-claim==0.4.0.dev2",
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
[build-system]
|
|
12
|
+
requires = ["poetry-core>=1.0.0"]
|
|
13
|
+
build-backend = "poetry.core.masonry.api"
|
|
14
|
+
|
|
15
|
+
[tool.poetry]
|
|
16
|
+
packages = [{ include = "tba_concrete_claim_authorization_context", from = "src" }]
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Draft generic DPoP authorization context; no assigned numeric CWT label."""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
|
|
5
|
+
from tba_bases_claim import ClaimBase
|
|
6
|
+
from tba_primitives_identity import ClaimType, ClaimValueType
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AuthorizationContextClaim(ClaimBase):
|
|
10
|
+
claim_name = "actx"
|
|
11
|
+
default_claim_type = ClaimType.AUTHORIZATION
|
|
12
|
+
default_value_type = ClaimValueType.JSON_OBJECT
|
|
13
|
+
default_standards = ("draft-nandakumar-moq-generic-dpop-proof-00",)
|
|
14
|
+
|
|
15
|
+
@classmethod
|
|
16
|
+
def validate_value(cls, value):
|
|
17
|
+
if not isinstance(value, Mapping) or not all(isinstance(key, str) for key in value):
|
|
18
|
+
raise ValueError("actx must be an object with string keys")
|
|
19
|
+
if not isinstance(value.get("type"), str) or not value["type"]:
|
|
20
|
+
raise ValueError("actx type must be a non-empty string")
|
|
21
|
+
|
|
22
|
+
def to_cwt_value(self, *, field_labels=None):
|
|
23
|
+
"""Encode context fields using an explicit protocol-specific label map."""
|
|
24
|
+
labels = dict(field_labels or {})
|
|
25
|
+
if "type" in labels or 0 in labels.values():
|
|
26
|
+
raise ValueError("actx key 0 is reserved for type")
|
|
27
|
+
if any(not isinstance(k, str) or isinstance(v, bool) or not isinstance(v, int)
|
|
28
|
+
for k, v in labels.items()) or len(set(labels.values())) != len(labels):
|
|
29
|
+
raise ValueError("actx field labels must be unique integers")
|
|
30
|
+
missing = set(self.value) - {"type"} - labels.keys()
|
|
31
|
+
if missing:
|
|
32
|
+
raise ValueError("actx protocol fields require explicit integer labels")
|
|
33
|
+
return {0 if key == "type" else labels[key]: value
|
|
34
|
+
for key, value in self.value.items()}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
__all__ = ["AuthorizationContextClaim"]
|
|
File without changes
|