tba-protocol-workload-spiffe-broker-api 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_protocol_workload_spiffe_broker_api-0.4.0.dev2/PKG-INFO +11 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/pyproject.toml +10 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/src/tba_protocol_workload_spiffe_broker_api/__init__.py +18 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/src/tba_protocol_workload_spiffe_broker_api/bindings.py +5 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/src/tba_protocol_workload_spiffe_broker_api/claims.py +5 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/src/tba_protocol_workload_spiffe_broker_api/compatibility.py +3 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/src/tba_protocol_workload_spiffe_broker_api/endpoint.py +3 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/src/tba_protocol_workload_spiffe_broker_api/errors.py +8 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/src/tba_protocol_workload_spiffe_broker_api/features.py +10 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/src/tba_protocol_workload_spiffe_broker_api/migrations.py +8 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/src/tba_protocol_workload_spiffe_broker_api/py.typed +0 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/src/tba_protocol_workload_spiffe_broker_api/references.py +18 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/src/tba_protocol_workload_spiffe_broker_api/rpcs.py +17 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/src/tba_protocol_workload_spiffe_broker_api/schemas.py +5 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/src/tba_protocol_workload_spiffe_broker_api/service.py +25 -0
- tba_protocol_workload_spiffe_broker_api-0.4.0.dev2/src/tba_protocol_workload_spiffe_broker_api/versions.py +16 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tba-protocol-workload-spiffe-broker-api
|
|
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
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name="tba-protocol-workload-spiffe-broker-api"
|
|
3
|
+
version="0.4.0.dev2"
|
|
4
|
+
requires-python=">=3.10,<3.15"
|
|
5
|
+
dependencies=[]
|
|
6
|
+
[build-system]
|
|
7
|
+
requires=["poetry-core>=1.0.0"]
|
|
8
|
+
build-backend="poetry.core.masonry.api"
|
|
9
|
+
[tool.poetry]
|
|
10
|
+
packages=[{include="tba_protocol_workload_spiffe_broker_api",from="src"}]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from .endpoint import validate_endpoint
|
|
2
|
+
from .references import BrokerWorkloadReference, normalize_reference
|
|
3
|
+
from .rpcs import RPC_DEFINITIONS, RPC_NAMES, BrokerRpcDefinition
|
|
4
|
+
from .service import BrokerApiService
|
|
5
|
+
from .versions import CURRENT_VERSION, VERSION_HISTORY, BrokerApiVersion
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"BrokerApiService",
|
|
9
|
+
"BrokerApiVersion",
|
|
10
|
+
"BrokerRpcDefinition",
|
|
11
|
+
"BrokerWorkloadReference",
|
|
12
|
+
"CURRENT_VERSION",
|
|
13
|
+
"RPC_DEFINITIONS",
|
|
14
|
+
"RPC_NAMES",
|
|
15
|
+
"VERSION_HISTORY",
|
|
16
|
+
"normalize_reference",
|
|
17
|
+
"validate_endpoint",
|
|
18
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Mapping
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass(frozen=True, slots=True)
|
|
6
|
+
class BrokerWorkloadReference:
|
|
7
|
+
kind: str
|
|
8
|
+
attributes: Mapping[str, object]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def normalize_reference(
|
|
12
|
+
kind: str, attributes: Mapping[str, object]
|
|
13
|
+
) -> BrokerWorkloadReference:
|
|
14
|
+
if kind not in {"pid", "kubernetes"}:
|
|
15
|
+
raise ValueError(f"unsupported broker workload reference: {kind}")
|
|
16
|
+
if not attributes:
|
|
17
|
+
raise ValueError("broker workload reference attributes are required")
|
|
18
|
+
return BrokerWorkloadReference(kind, dict(attributes))
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@dataclass(frozen=True, slots=True)
|
|
5
|
+
class BrokerRpcDefinition:
|
|
6
|
+
name: str
|
|
7
|
+
server_streaming: bool
|
|
8
|
+
profile: str
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
RPC_DEFINITIONS = (
|
|
12
|
+
BrokerRpcDefinition("SubscribeToX509SVID", True, "x509-svid"),
|
|
13
|
+
BrokerRpcDefinition("SubscribeToX509Bundles", True, "x509-svid"),
|
|
14
|
+
BrokerRpcDefinition("FetchJWTSVID", False, "jwt-svid"),
|
|
15
|
+
BrokerRpcDefinition("SubscribeToJWTBundles", True, "jwt-svid"),
|
|
16
|
+
)
|
|
17
|
+
RPC_NAMES = frozenset(item.name for item in RPC_DEFINITIONS)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from collections.abc import Callable, Mapping
|
|
2
|
+
from .rpcs import RPC_NAMES
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class BrokerApiService:
|
|
6
|
+
def __init__(
|
|
7
|
+
self,
|
|
8
|
+
*,
|
|
9
|
+
authorize: Callable[[object], bool],
|
|
10
|
+
handlers: Mapping[str, Callable[..., object]],
|
|
11
|
+
) -> None:
|
|
12
|
+
unknown = set(handlers).difference(RPC_NAMES)
|
|
13
|
+
missing = RPC_NAMES.difference(handlers)
|
|
14
|
+
if unknown or missing:
|
|
15
|
+
raise ValueError(
|
|
16
|
+
f"Broker API handler mismatch; unknown={sorted(unknown)}, missing={sorted(missing)}"
|
|
17
|
+
)
|
|
18
|
+
self._authorize, self._handlers = authorize, dict(handlers)
|
|
19
|
+
|
|
20
|
+
def dispatch(self, actor: object, rpc: str, request: object) -> object:
|
|
21
|
+
if not self._authorize(actor):
|
|
22
|
+
raise PermissionError("broker caller is not authorized")
|
|
23
|
+
if rpc not in RPC_NAMES:
|
|
24
|
+
raise ValueError(f"unknown Broker API RPC: {rpc}")
|
|
25
|
+
return self._handlers[rpc](request)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@dataclass(frozen=True, slots=True)
|
|
5
|
+
class BrokerApiVersion:
|
|
6
|
+
identifier: str
|
|
7
|
+
status: str
|
|
8
|
+
specification_uri: str
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
CURRENT_VERSION = BrokerApiVersion(
|
|
12
|
+
"SPIFFE-v1.15.1-Broker-API",
|
|
13
|
+
"Incubating",
|
|
14
|
+
"https://github.com/spiffe/spiffe/tree/v1.15.1",
|
|
15
|
+
)
|
|
16
|
+
VERSION_HISTORY = (CURRENT_VERSION,)
|