tba-profile-workload-credential-wimse-wit 0.4.0.dev2__tar.gz → 0.4.0.dev3__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_profile_workload_credential_wimse_wit-0.4.0.dev3/PKG-INFO +59 -0
- tba_profile_workload_credential_wimse_wit-0.4.0.dev3/README.md +40 -0
- tba_profile_workload_credential_wimse_wit-0.4.0.dev3/pyproject.toml +26 -0
- {tba_profile_workload_credential_wimse_wit-0.4.0.dev2 → tba_profile_workload_credential_wimse_wit-0.4.0.dev3}/src/tba_profile_workload_credential_wimse_wit/__init__.py +5 -0
- tba_profile_workload_credential_wimse_wit-0.4.0.dev3/src/tba_profile_workload_credential_wimse_wit/compatibility.py +6 -0
- tba_profile_workload_credential_wimse_wit-0.4.0.dev3/src/tba_profile_workload_credential_wimse_wit/issuance.py +52 -0
- {tba_profile_workload_credential_wimse_wit-0.4.0.dev2 → tba_profile_workload_credential_wimse_wit-0.4.0.dev3}/src/tba_profile_workload_credential_wimse_wit/migrations.py +4 -1
- tba_profile_workload_credential_wimse_wit-0.4.0.dev3/src/tba_profile_workload_credential_wimse_wit/verification.py +48 -0
- {tba_profile_workload_credential_wimse_wit-0.4.0.dev2 → tba_profile_workload_credential_wimse_wit-0.4.0.dev3}/src/tba_profile_workload_credential_wimse_wit/versions.py +7 -2
- tba_profile_workload_credential_wimse_wit-0.4.0.dev2/PKG-INFO +0 -11
- tba_profile_workload_credential_wimse_wit-0.4.0.dev2/pyproject.toml +0 -10
- tba_profile_workload_credential_wimse_wit-0.4.0.dev2/src/tba_profile_workload_credential_wimse_wit/compatibility.py +0 -3
- {tba_profile_workload_credential_wimse_wit-0.4.0.dev2 → tba_profile_workload_credential_wimse_wit-0.4.0.dev3}/src/tba_profile_workload_credential_wimse_wit/bindings.py +0 -0
- {tba_profile_workload_credential_wimse_wit-0.4.0.dev2 → tba_profile_workload_credential_wimse_wit-0.4.0.dev3}/src/tba_profile_workload_credential_wimse_wit/claims.py +0 -0
- {tba_profile_workload_credential_wimse_wit-0.4.0.dev2 → tba_profile_workload_credential_wimse_wit-0.4.0.dev3}/src/tba_profile_workload_credential_wimse_wit/errors.py +0 -0
- {tba_profile_workload_credential_wimse_wit-0.4.0.dev2 → tba_profile_workload_credential_wimse_wit-0.4.0.dev3}/src/tba_profile_workload_credential_wimse_wit/features.py +0 -0
- {tba_profile_workload_credential_wimse_wit-0.4.0.dev2 → tba_profile_workload_credential_wimse_wit-0.4.0.dev3}/src/tba_profile_workload_credential_wimse_wit/py.typed +0 -0
- {tba_profile_workload_credential_wimse_wit-0.4.0.dev2 → tba_profile_workload_credential_wimse_wit-0.4.0.dev3}/src/tba_profile_workload_credential_wimse_wit/schemas.py +0 -0
- {tba_profile_workload_credential_wimse_wit-0.4.0.dev2 → tba_profile_workload_credential_wimse_wit-0.4.0.dev3}/src/tba_profile_workload_credential_wimse_wit/validation.py +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tba-profile-workload-credential-wimse-wit
|
|
3
|
+
Version: 0.4.0.dev3
|
|
4
|
+
Summary: WIMSE Workload Identity Token.
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Requires-Python: >=3.10,<3.16
|
|
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
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
13
|
+
Requires-Dist: tba-concrete-jwt (==0.4.0.dev2)
|
|
14
|
+
Requires-Dist: tba-concrete-wit (==0.4.0.dev2)
|
|
15
|
+
Requires-Dist: tba-protocol-workload-wimse-identifier (==0.4.0.dev2)
|
|
16
|
+
Requires-Dist: tba-provider-jose-cryptography (==0.4.0.dev3)
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# tba-profile-workload-credential-wimse-wit
|
|
20
|
+
|
|
21
|
+
<!-- BEGIN TBA README HEADER -->
|
|
22
|
+
<p align="center">
|
|
23
|
+
<a href="https://github.com/tigrbl/tigrbl_auth#readme"><img src="https://raw.githubusercontent.com/tigrbl/tigrbl_auth/master/docs/assets/tba-brand.png" alt="TBA · Tigrbl Auth" width="240"></a>
|
|
24
|
+
</p>
|
|
25
|
+
<p align="center">
|
|
26
|
+
<a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/55-profiles/tba-profile-workload-credential-wimse-wit/pyproject.toml"><img alt="Checkout: 0.4.0.dev2" src="https://img.shields.io/badge/Checkout-0.4.0.dev2-1f6feb"></a>
|
|
27
|
+
<a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/55-profiles/tba-profile-workload-credential-wimse-wit/pyproject.toml"><img alt="Python: >=3.10,<3.16" src="https://img.shields.io/badge/Python-%3E%3D3.10%2C%3C3.16-3776ab"></a>
|
|
28
|
+
<a href="https://github.com/tigrbl/tigrbl_auth/tree/master/pkgs/55-profiles"><img alt="Layer: 55 profiles" src="https://img.shields.io/badge/Layer-55%20profiles-0a7f5a"></a>
|
|
29
|
+
<a href="https://pypi.org/project/tba-profile-workload-credential-wimse-wit/"><img alt="PyPI version for tba-profile-workload-credential-wimse-wit" src="https://img.shields.io/pypi/v/tba-profile-workload-credential-wimse-wit?label=tba-profile-workload-credential-wimse-wit%20PyPI"></a>
|
|
30
|
+
</p>
|
|
31
|
+
<p align="center">
|
|
32
|
+
<a href="https://pepy.tech/project/tba-profile-workload-credential-wimse-wit"><img alt="Monthly PyPI downloads for tba-profile-workload-credential-wimse-wit" src="https://static.pepy.tech/badge/tba-profile-workload-credential-wimse-wit/month"></a>
|
|
33
|
+
<a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/55-profiles/tba-profile-workload-credential-wimse-wit/README.md#verification"><img alt="Evidence: verification" src="https://img.shields.io/badge/Evidence-verification-8250df"></a>
|
|
34
|
+
</p>
|
|
35
|
+
<!-- END TBA README HEADER -->
|
|
36
|
+
|
|
37
|
+
WIMSE Workload Identity Token. This is a revision-pinned IETF draft profile and is disabled by default at runtime.
|
|
38
|
+
|
|
39
|
+
## Quick start
|
|
40
|
+
|
|
41
|
+
With [uv](https://docs.astral.sh/uv/) available, save the example as `quickstart.py`. This command uses the published package in an isolated Python 3.12 environment.
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from tba_profile_workload_credential_wimse_wit import CURRENT_VERSION
|
|
45
|
+
|
|
46
|
+
assert CURRENT_VERSION is not None
|
|
47
|
+
print(CURRENT_VERSION)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
uv run --isolated --no-project --python 3.12 --with "tba-profile-workload-credential-wimse-wit==0.4.0.dev2" python quickstart.py
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The command prints the declared current revision.
|
|
55
|
+
|
|
56
|
+
## Verification
|
|
57
|
+
|
|
58
|
+
The quick start was run with the pinned distribution from PyPI and its declared dependencies. See the [public package entry point](https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/55-profiles/tba-profile-workload-credential-wimse-wit/src/tba_profile_workload_credential_wimse_wit/__init__.py).
|
|
59
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# tba-profile-workload-credential-wimse-wit
|
|
2
|
+
|
|
3
|
+
<!-- BEGIN TBA README HEADER -->
|
|
4
|
+
<p align="center">
|
|
5
|
+
<a href="https://github.com/tigrbl/tigrbl_auth#readme"><img src="https://raw.githubusercontent.com/tigrbl/tigrbl_auth/master/docs/assets/tba-brand.png" alt="TBA · Tigrbl Auth" width="240"></a>
|
|
6
|
+
</p>
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/55-profiles/tba-profile-workload-credential-wimse-wit/pyproject.toml"><img alt="Checkout: 0.4.0.dev2" src="https://img.shields.io/badge/Checkout-0.4.0.dev2-1f6feb"></a>
|
|
9
|
+
<a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/55-profiles/tba-profile-workload-credential-wimse-wit/pyproject.toml"><img alt="Python: >=3.10,<3.16" src="https://img.shields.io/badge/Python-%3E%3D3.10%2C%3C3.16-3776ab"></a>
|
|
10
|
+
<a href="https://github.com/tigrbl/tigrbl_auth/tree/master/pkgs/55-profiles"><img alt="Layer: 55 profiles" src="https://img.shields.io/badge/Layer-55%20profiles-0a7f5a"></a>
|
|
11
|
+
<a href="https://pypi.org/project/tba-profile-workload-credential-wimse-wit/"><img alt="PyPI version for tba-profile-workload-credential-wimse-wit" src="https://img.shields.io/pypi/v/tba-profile-workload-credential-wimse-wit?label=tba-profile-workload-credential-wimse-wit%20PyPI"></a>
|
|
12
|
+
</p>
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="https://pepy.tech/project/tba-profile-workload-credential-wimse-wit"><img alt="Monthly PyPI downloads for tba-profile-workload-credential-wimse-wit" src="https://static.pepy.tech/badge/tba-profile-workload-credential-wimse-wit/month"></a>
|
|
15
|
+
<a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/55-profiles/tba-profile-workload-credential-wimse-wit/README.md#verification"><img alt="Evidence: verification" src="https://img.shields.io/badge/Evidence-verification-8250df"></a>
|
|
16
|
+
</p>
|
|
17
|
+
<!-- END TBA README HEADER -->
|
|
18
|
+
|
|
19
|
+
WIMSE Workload Identity Token. This is a revision-pinned IETF draft profile and is disabled by default at runtime.
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
With [uv](https://docs.astral.sh/uv/) available, save the example as `quickstart.py`. This command uses the published package in an isolated Python 3.12 environment.
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from tba_profile_workload_credential_wimse_wit import CURRENT_VERSION
|
|
27
|
+
|
|
28
|
+
assert CURRENT_VERSION is not None
|
|
29
|
+
print(CURRENT_VERSION)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
uv run --isolated --no-project --python 3.12 --with "tba-profile-workload-credential-wimse-wit==0.4.0.dev2" python quickstart.py
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The command prints the declared current revision.
|
|
37
|
+
|
|
38
|
+
## Verification
|
|
39
|
+
|
|
40
|
+
The quick start was run with the pinned distribution from PyPI and its declared dependencies. See the [public package entry point](https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/55-profiles/tba-profile-workload-credential-wimse-wit/src/tba_profile_workload_credential_wimse_wit/__init__.py).
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name="tba-profile-workload-credential-wimse-wit"
|
|
3
|
+
version="0.4.0.dev3"
|
|
4
|
+
description = "WIMSE Workload Identity Token."
|
|
5
|
+
license = { text = "Apache-2.0" }
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
requires-python=">=3.10,<3.16"
|
|
8
|
+
classifiers = [
|
|
9
|
+
"Programming Language :: Python :: 3.10",
|
|
10
|
+
"Programming Language :: Python :: 3.11",
|
|
11
|
+
"Programming Language :: Python :: 3.12",
|
|
12
|
+
"Programming Language :: Python :: 3.13",
|
|
13
|
+
"Programming Language :: Python :: 3.14",
|
|
14
|
+
"Programming Language :: Python :: 3.15",
|
|
15
|
+
]
|
|
16
|
+
dependencies = [
|
|
17
|
+
"tba-concrete-jwt==0.4.0.dev2",
|
|
18
|
+
"tba-concrete-wit==0.4.0.dev2",
|
|
19
|
+
"tba-protocol-workload-wimse-identifier==0.4.0.dev2",
|
|
20
|
+
"tba-provider-jose-cryptography==0.4.0.dev3",
|
|
21
|
+
]
|
|
22
|
+
[build-system]
|
|
23
|
+
requires=["poetry-core>=1.0.0"]
|
|
24
|
+
build-backend="poetry.core.masonry.api"
|
|
25
|
+
[tool.poetry]
|
|
26
|
+
packages=[{include="tba_profile_workload_credential_wimse_wit",from="src"}]
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
|
|
3
|
+
from tba_protocol_workload_wimse_identifier import WorkloadIdentifier
|
|
4
|
+
from tba_provider_jose_cryptography.jws import (
|
|
5
|
+
ProtectedEnvelopeIssuerPort,
|
|
6
|
+
sign_compact_jwt,
|
|
7
|
+
)
|
|
8
|
+
from tba_provider_jose_cryptography.public_jws import public_jwk_key
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def issue_wit(
|
|
12
|
+
signer: ProtectedEnvelopeIssuerPort,
|
|
13
|
+
*,
|
|
14
|
+
subject: str,
|
|
15
|
+
confirmation_jwk: Mapping[str, str],
|
|
16
|
+
issuer_key_reference: str,
|
|
17
|
+
issuer_key_id: str,
|
|
18
|
+
issuer_algorithm: str,
|
|
19
|
+
issued_at: int,
|
|
20
|
+
expires_at: int,
|
|
21
|
+
) -> str:
|
|
22
|
+
"""Issue a workload credential using the configured trust-domain signer."""
|
|
23
|
+
if (
|
|
24
|
+
type(issued_at) is not int
|
|
25
|
+
or type(expires_at) is not int
|
|
26
|
+
or expires_at <= issued_at
|
|
27
|
+
):
|
|
28
|
+
raise ValueError("WIT expiry must follow issuance")
|
|
29
|
+
if (
|
|
30
|
+
not issuer_key_id
|
|
31
|
+
or issuer_algorithm.lower() == "none"
|
|
32
|
+
or issuer_algorithm.startswith("HS")
|
|
33
|
+
or not issuer_algorithm
|
|
34
|
+
):
|
|
35
|
+
raise ValueError("WIT requires an identified asymmetric signing key")
|
|
36
|
+
confirmation = dict(confirmation_jwk)
|
|
37
|
+
algorithm = confirmation.get("alg")
|
|
38
|
+
if not isinstance(algorithm, str):
|
|
39
|
+
raise ValueError("WIT confirmation JWK requires a signing algorithm")
|
|
40
|
+
public_jwk_key(confirmation, algorithm)
|
|
41
|
+
claims = {
|
|
42
|
+
"sub": str(WorkloadIdentifier.parse(subject)),
|
|
43
|
+
"cnf": {"jwk": confirmation},
|
|
44
|
+
"iat": issued_at,
|
|
45
|
+
"exp": expires_at,
|
|
46
|
+
}
|
|
47
|
+
return sign_compact_jwt(
|
|
48
|
+
signer,
|
|
49
|
+
claims,
|
|
50
|
+
headers={"typ": "wit+jwt", "alg": issuer_algorithm, "kid": issuer_key_id},
|
|
51
|
+
key_reference=issuer_key_reference,
|
|
52
|
+
)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from math import isfinite
|
|
3
|
+
|
|
4
|
+
from dataclasses import replace
|
|
5
|
+
|
|
6
|
+
from tba_concrete_jwt import decode_jwt_unverified
|
|
7
|
+
from tba_concrete_wit import WorkloadIdentityToken
|
|
8
|
+
from tba_protocol_workload_wimse_identifier import WorkloadIdentifier
|
|
9
|
+
from tba_provider_jose_cryptography.public_jws import public_jwk_key, verify_public_jws
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def verify_wit(
|
|
13
|
+
serialized: str, *, trust_by_domain, now: float
|
|
14
|
+
) -> WorkloadIdentityToken:
|
|
15
|
+
token = decode_jwt_unverified(serialized)
|
|
16
|
+
headers = token.jws.protected_headers
|
|
17
|
+
if headers.get("typ") not in ("wit+jwt", "application/wit+jwt"):
|
|
18
|
+
raise ValueError("invalid WIT media type")
|
|
19
|
+
claims = token.claims
|
|
20
|
+
identifier = WorkloadIdentifier.parse(claims.get("sub"))
|
|
21
|
+
expiration = claims.get("exp")
|
|
22
|
+
not_before = claims.get("nbf", now)
|
|
23
|
+
if any(
|
|
24
|
+
type(value) not in (int, float) or not isfinite(value)
|
|
25
|
+
for value in (expiration, not_before)
|
|
26
|
+
):
|
|
27
|
+
raise ValueError("invalid WIT lifetime")
|
|
28
|
+
if not not_before <= now < expiration:
|
|
29
|
+
raise ValueError("WIT is outside its validity period")
|
|
30
|
+
if "iss" in claims and not isinstance(claims["iss"], str):
|
|
31
|
+
raise ValueError("invalid WIT issuer")
|
|
32
|
+
confirmation = claims.get("cnf")
|
|
33
|
+
jwk = confirmation.get("jwk") if isinstance(confirmation, Mapping) else None
|
|
34
|
+
if not isinstance(jwk, Mapping) or not isinstance(jwk.get("alg"), str):
|
|
35
|
+
raise ValueError("WIT requires a public confirmation JWK with an algorithm")
|
|
36
|
+
public_jwk_key(jwk, jwk["alg"])
|
|
37
|
+
keys = tuple(trust_by_domain.get(identifier.trust_domain, ()))
|
|
38
|
+
kid = headers.get("kid")
|
|
39
|
+
if "kid" in headers:
|
|
40
|
+
if not isinstance(kid, str) or not kid:
|
|
41
|
+
raise ValueError("invalid WIT signing key ID")
|
|
42
|
+
keys = tuple(key for key in keys if key.get("kid") == kid)
|
|
43
|
+
if len(keys) != 1:
|
|
44
|
+
raise ValueError(
|
|
45
|
+
"WIT signing key must resolve uniquely within its trust domain"
|
|
46
|
+
)
|
|
47
|
+
verify_public_jws(serialized, keys[0])
|
|
48
|
+
return WorkloadIdentityToken(replace(token, integrity_verified=True))
|
|
@@ -8,9 +8,14 @@ class WitVersion:
|
|
|
8
8
|
specification_uri: str
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
LEGACY_VERSION = WitVersion(
|
|
12
12
|
"draft-ietf-wimse-workload-creds-02",
|
|
13
13
|
"IETF-draft",
|
|
14
14
|
"https://datatracker.ietf.org/doc/draft-ietf-wimse-workload-creds/02/",
|
|
15
15
|
)
|
|
16
|
-
|
|
16
|
+
CURRENT_VERSION = WitVersion(
|
|
17
|
+
"draft-ietf-wimse-workload-creds-03",
|
|
18
|
+
"IETF-draft",
|
|
19
|
+
"https://datatracker.ietf.org/doc/html/draft-ietf-wimse-workload-creds-03",
|
|
20
|
+
)
|
|
21
|
+
VERSION_HISTORY = (LEGACY_VERSION, CURRENT_VERSION)
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: tba-profile-workload-credential-wimse-wit
|
|
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
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
[project]
|
|
2
|
-
name="tba-profile-workload-credential-wimse-wit"
|
|
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_profile_workload_credential_wimse_wit",from="src"}]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|