swarmauri_keyprovider_aws_kms 0.3.0.dev4__tar.gz → 0.3.0.dev22__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,150 @@
1
+ Metadata-Version: 2.4
2
+ Name: swarmauri_keyprovider_aws_kms
3
+ Version: 0.3.0.dev22
4
+ Summary: AWS KMS KeyProvider for Swarmauri
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Keywords: swarmauri,keyprovider,aws,kms
8
+ Author: Jacob Stewart
9
+ Author-email: jacob@swarmauri.com
10
+ Requires-Python: >=3.10,<3.13
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Natural Language :: English
16
+ Classifier: Development Status :: 3 - Alpha
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
19
+ Provides-Extra: perf
20
+ Requires-Dist: boto3 (>=1.28.0)
21
+ Requires-Dist: cryptography
22
+ Requires-Dist: pytest-benchmark (>=4.0.0) ; extra == "perf"
23
+ Requires-Dist: swarmauri_base
24
+ Requires-Dist: swarmauri_core
25
+ Requires-Dist: swarmauri_standard
26
+ Description-Content-Type: text/markdown
27
+
28
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
29
+
30
+ <p align="center">
31
+ <a href="https://pypi.org/project/swarmauri_keyprovider_aws_kms/">
32
+ <img src="https://img.shields.io/pypi/dm/swarmauri_keyprovider_aws_kms" alt="PyPI - Downloads"/></a>
33
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_keyprovider_aws_kms/">
34
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_keyprovider_aws_kms.svg"/></a>
35
+ <a href="https://pypi.org/project/swarmauri_keyprovider_aws_kms/">
36
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_keyprovider_aws_kms" alt="PyPI - Python Version"/></a>
37
+ <a href="https://pypi.org/project/swarmauri_keyprovider_aws_kms/">
38
+ <img src="https://img.shields.io/pypi/l/swarmauri_keyprovider_aws_kms" alt="PyPI - License"/></a>
39
+ <a href="https://pypi.org/project/swarmauri_keyprovider_aws_kms/">
40
+ <img src="https://img.shields.io/pypi/v/swarmauri_keyprovider_aws_kms?label=swarmauri_keyprovider_aws_kms&color=green" alt="PyPI - swarmauri_keyprovider_aws_kms"/></a>
41
+
42
+ </p>
43
+
44
+ ---
45
+
46
+ # Swarmauri AWS KMS Key Provider
47
+
48
+ Community plugin providing an AWS Key Management Service (KMS) backed `KeyProvider` for Swarmauri. It manages non-exportable customer managed keys (CMKs), exposes JWKS for downstream services, and handles key rotation workflows aligned with AWS best practices.
49
+
50
+ ## Features
51
+
52
+ - Create RSA, ECC, and AES-256 keys in AWS KMS with deterministic aliasing per `kid` and version.
53
+ - Rotate keys by minting new KMS key versions and updating aliases, while preserving previous versions for auditing or staged cutovers.
54
+ - Describe keys through `KeyRef` objects, including public PEM material when the key spec allows export, and RFC 7517-compliant JWKs via `get_public_jwk`/`jwks`.
55
+ - Generate cryptographically secure random bytes and perform HKDF expansion with SHA-256 to support envelope encryption and symmetric derivation flows.
56
+ - Destroy keys by scheduling deletion through the KMS API, maintaining Swarmauri tagging metadata for traceability.
57
+
58
+ ## Prerequisites
59
+
60
+ - Python 3.10 or newer.
61
+ - `boto3` (installed automatically with this package) and network access to the target AWS region.
62
+ - AWS credentials with permissions such as `kms:CreateKey`, `kms:CreateAlias`, `kms:UpdateAlias`, `kms:DescribeKey`, `kms:GetPublicKey`, `kms:ListAliases`, `kms:ListResourceTags`, and `kms:ScheduleKeyDeletion`.
63
+ - Optional: a custom key policy if you need to delegate key administration to non-root principals; pass it through the `key_policy` constructor argument.
64
+
65
+ ## Installation
66
+
67
+ ```bash
68
+ # pip
69
+ pip install swarmauri_keyprovider_aws_kms
70
+
71
+ # poetry
72
+ poetry add swarmauri_keyprovider_aws_kms
73
+
74
+ # uv (pyproject-based projects)
75
+ uv add swarmauri_keyprovider_aws_kms
76
+ ```
77
+
78
+ ## Quickstart: Create, Rotate, and Publish Keys
79
+
80
+ ```python
81
+ import asyncio
82
+ from swarmauri_keyprovider_aws_kms import AwsKmsKeyProvider
83
+ from swarmauri_core.key_providers.types import KeyAlg, KeyClass, KeySpec, ExportPolicy
84
+
85
+
86
+ async def main() -> None:
87
+ provider = AwsKmsKeyProvider(region="us-east-1", alias_prefix="swarmauri-demo")
88
+
89
+ rsa_spec = KeySpec(
90
+ klass=KeyClass.asymmetric,
91
+ alg=KeyAlg.RSA_PSS_SHA256,
92
+ size_bits=3072,
93
+ export_policy=ExportPolicy.never_export_secret,
94
+ label="api-signing",
95
+ )
96
+
97
+ # Create the initial version (aliases: alias/swarmauri-demo/<kid> and .../v1)
98
+ key_ref = await provider.create_key(rsa_spec)
99
+ print("KID", key_ref.kid, "version", key_ref.version)
100
+
101
+ # Surface the public JWK for JWT signing or JWKS endpoints
102
+ jwk = await provider.get_public_jwk(key_ref.kid)
103
+ print("Public JWK", jwk)
104
+
105
+ # Rotate the key – new CMK in KMS, version alias bump, old alias retained
106
+ rotated = await provider.rotate_key(key_ref.kid)
107
+ print("Rotated to version", rotated.version)
108
+
109
+ # Publish the aggregate JWKS (includes the latest version per kid)
110
+ jwks_payload = await provider.jwks()
111
+ print("JWKS keys", [k["kid"] for k in jwks_payload["keys"]])
112
+
113
+
114
+ if __name__ == "__main__":
115
+ asyncio.run(main())
116
+ ```
117
+
118
+ ## Symmetric Utilities: Random Bytes and HKDF
119
+
120
+ ```python
121
+ import asyncio
122
+ from swarmauri_keyprovider_aws_kms import AwsKmsKeyProvider
123
+
124
+
125
+ async def derive_data_key() -> bytes:
126
+ provider = AwsKmsKeyProvider(region="us-east-1")
127
+
128
+ master_salt = await provider.random_bytes(32)
129
+ info = b"swarmauri/example"
130
+
131
+ pseudo_random_key = await provider.random_bytes(32)
132
+ derived = await provider.hkdf(
133
+ pseudo_random_key,
134
+ salt=master_salt,
135
+ info=info,
136
+ length=32,
137
+ )
138
+ return derived
139
+
140
+
141
+ # asyncio.run(derive_data_key())
142
+ ```
143
+
144
+ ## Operational Tips
145
+
146
+ - `list_versions(kid)` inspects versioned aliases (`alias/<prefix>/<kid>/vN`); use it before destructive actions to ensure you capture all active CMKs.
147
+ - Destroying a key schedules deletion for 7 days. Plan rotations ahead of time so dependent systems can migrate to the new version before you call `destroy_key`.
148
+ - Tag metadata persisted by the provider (`saur:kid`, `saur:version`, `saur:alg`, optional `saur:label`) enables inventory checks—query them from the AWS console or CLI when auditing.
149
+ - For high-throughput signing, ensure your IAM policies, KMS quotas, and region placement match latency expectations; consider caching public JWKs from `jwks()` in your verifier services.
150
+
@@ -0,0 +1,122 @@
1
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
2
+
3
+ <p align="center">
4
+ <a href="https://pypi.org/project/swarmauri_keyprovider_aws_kms/">
5
+ <img src="https://img.shields.io/pypi/dm/swarmauri_keyprovider_aws_kms" alt="PyPI - Downloads"/></a>
6
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_keyprovider_aws_kms/">
7
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_keyprovider_aws_kms.svg"/></a>
8
+ <a href="https://pypi.org/project/swarmauri_keyprovider_aws_kms/">
9
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_keyprovider_aws_kms" alt="PyPI - Python Version"/></a>
10
+ <a href="https://pypi.org/project/swarmauri_keyprovider_aws_kms/">
11
+ <img src="https://img.shields.io/pypi/l/swarmauri_keyprovider_aws_kms" alt="PyPI - License"/></a>
12
+ <a href="https://pypi.org/project/swarmauri_keyprovider_aws_kms/">
13
+ <img src="https://img.shields.io/pypi/v/swarmauri_keyprovider_aws_kms?label=swarmauri_keyprovider_aws_kms&color=green" alt="PyPI - swarmauri_keyprovider_aws_kms"/></a>
14
+
15
+ </p>
16
+
17
+ ---
18
+
19
+ # Swarmauri AWS KMS Key Provider
20
+
21
+ Community plugin providing an AWS Key Management Service (KMS) backed `KeyProvider` for Swarmauri. It manages non-exportable customer managed keys (CMKs), exposes JWKS for downstream services, and handles key rotation workflows aligned with AWS best practices.
22
+
23
+ ## Features
24
+
25
+ - Create RSA, ECC, and AES-256 keys in AWS KMS with deterministic aliasing per `kid` and version.
26
+ - Rotate keys by minting new KMS key versions and updating aliases, while preserving previous versions for auditing or staged cutovers.
27
+ - Describe keys through `KeyRef` objects, including public PEM material when the key spec allows export, and RFC 7517-compliant JWKs via `get_public_jwk`/`jwks`.
28
+ - Generate cryptographically secure random bytes and perform HKDF expansion with SHA-256 to support envelope encryption and symmetric derivation flows.
29
+ - Destroy keys by scheduling deletion through the KMS API, maintaining Swarmauri tagging metadata for traceability.
30
+
31
+ ## Prerequisites
32
+
33
+ - Python 3.10 or newer.
34
+ - `boto3` (installed automatically with this package) and network access to the target AWS region.
35
+ - AWS credentials with permissions such as `kms:CreateKey`, `kms:CreateAlias`, `kms:UpdateAlias`, `kms:DescribeKey`, `kms:GetPublicKey`, `kms:ListAliases`, `kms:ListResourceTags`, and `kms:ScheduleKeyDeletion`.
36
+ - Optional: a custom key policy if you need to delegate key administration to non-root principals; pass it through the `key_policy` constructor argument.
37
+
38
+ ## Installation
39
+
40
+ ```bash
41
+ # pip
42
+ pip install swarmauri_keyprovider_aws_kms
43
+
44
+ # poetry
45
+ poetry add swarmauri_keyprovider_aws_kms
46
+
47
+ # uv (pyproject-based projects)
48
+ uv add swarmauri_keyprovider_aws_kms
49
+ ```
50
+
51
+ ## Quickstart: Create, Rotate, and Publish Keys
52
+
53
+ ```python
54
+ import asyncio
55
+ from swarmauri_keyprovider_aws_kms import AwsKmsKeyProvider
56
+ from swarmauri_core.key_providers.types import KeyAlg, KeyClass, KeySpec, ExportPolicy
57
+
58
+
59
+ async def main() -> None:
60
+ provider = AwsKmsKeyProvider(region="us-east-1", alias_prefix="swarmauri-demo")
61
+
62
+ rsa_spec = KeySpec(
63
+ klass=KeyClass.asymmetric,
64
+ alg=KeyAlg.RSA_PSS_SHA256,
65
+ size_bits=3072,
66
+ export_policy=ExportPolicy.never_export_secret,
67
+ label="api-signing",
68
+ )
69
+
70
+ # Create the initial version (aliases: alias/swarmauri-demo/<kid> and .../v1)
71
+ key_ref = await provider.create_key(rsa_spec)
72
+ print("KID", key_ref.kid, "version", key_ref.version)
73
+
74
+ # Surface the public JWK for JWT signing or JWKS endpoints
75
+ jwk = await provider.get_public_jwk(key_ref.kid)
76
+ print("Public JWK", jwk)
77
+
78
+ # Rotate the key – new CMK in KMS, version alias bump, old alias retained
79
+ rotated = await provider.rotate_key(key_ref.kid)
80
+ print("Rotated to version", rotated.version)
81
+
82
+ # Publish the aggregate JWKS (includes the latest version per kid)
83
+ jwks_payload = await provider.jwks()
84
+ print("JWKS keys", [k["kid"] for k in jwks_payload["keys"]])
85
+
86
+
87
+ if __name__ == "__main__":
88
+ asyncio.run(main())
89
+ ```
90
+
91
+ ## Symmetric Utilities: Random Bytes and HKDF
92
+
93
+ ```python
94
+ import asyncio
95
+ from swarmauri_keyprovider_aws_kms import AwsKmsKeyProvider
96
+
97
+
98
+ async def derive_data_key() -> bytes:
99
+ provider = AwsKmsKeyProvider(region="us-east-1")
100
+
101
+ master_salt = await provider.random_bytes(32)
102
+ info = b"swarmauri/example"
103
+
104
+ pseudo_random_key = await provider.random_bytes(32)
105
+ derived = await provider.hkdf(
106
+ pseudo_random_key,
107
+ salt=master_salt,
108
+ info=info,
109
+ length=32,
110
+ )
111
+ return derived
112
+
113
+
114
+ # asyncio.run(derive_data_key())
115
+ ```
116
+
117
+ ## Operational Tips
118
+
119
+ - `list_versions(kid)` inspects versioned aliases (`alias/<prefix>/<kid>/vN`); use it before destructive actions to ensure you capture all active CMKs.
120
+ - Destroying a key schedules deletion for 7 days. Plan rotations ahead of time so dependent systems can migrate to the new version before you call `destroy_key`.
121
+ - Tag metadata persisted by the provider (`saur:kid`, `saur:version`, `saur:alg`, optional `saur:label`) enables inventory checks—query them from the AWS console or CLI when auditing.
122
+ - For high-throughput signing, ensure your IAM policies, KMS quotas, and region placement match latency expectations; consider caching public JWKs from `jwks()` in your verifier services.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "swarmauri_keyprovider_aws_kms"
3
- version = "0.3.0.dev4"
3
+ version = "0.3.0.dev22"
4
4
  description = "AWS KMS KeyProvider for Swarmauri"
5
5
  license = "Apache-2.0"
6
6
  readme = "README.md"
@@ -11,8 +11,12 @@ classifiers = [
11
11
  "Programming Language :: Python :: 3.10",
12
12
  "Programming Language :: Python :: 3.11",
13
13
  "Programming Language :: Python :: 3.12",
14
+ "Natural Language :: English",
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
14
18
  ]
15
- authors = [{ name = "Swarmauri", email = "opensource@swarmauri.com" }]
19
+ authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
16
20
  dependencies = [
17
21
  "boto3>=1.28.0",
18
22
  "swarmauri_core",
@@ -20,9 +24,14 @@ dependencies = [
20
24
  "swarmauri_standard",
21
25
  "cryptography",
22
26
  ]
27
+ keywords = [
28
+ "swarmauri",
29
+ "keyprovider",
30
+ "aws",
31
+ "kms",
32
+ ]
23
33
 
24
34
  [project.optional-dependencies]
25
- docs = ["mkdocs"]
26
35
  perf = ["pytest-benchmark>=4.0.0"]
27
36
 
28
37
  [tool.uv.sources]
@@ -17,8 +17,14 @@ except Exception as e: # pragma: no cover
17
17
  from cryptography.hazmat.primitives import serialization
18
18
  from cryptography.hazmat.primitives.asymmetric import rsa, ec
19
19
 
20
- from swarmauri_base.keys.KeyProviderBase import KeyProviderBase
21
- from swarmauri_core.keys.types import KeySpec, KeyAlg, KeyClass, ExportPolicy, KeyUse
20
+ from swarmauri_base.key_providers.KeyProviderBase import KeyProviderBase
21
+ from swarmauri_core.key_providers.types import (
22
+ KeySpec,
23
+ KeyAlg,
24
+ KeyClass,
25
+ ExportPolicy,
26
+ KeyUse,
27
+ )
22
28
  from swarmauri_core.crypto.types import KeyRef
23
29
 
24
30
 
@@ -1,44 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: swarmauri_keyprovider_aws_kms
3
- Version: 0.3.0.dev4
4
- Summary: AWS KMS KeyProvider for Swarmauri
5
- License: Apache-2.0
6
- Author: Swarmauri
7
- Author-email: opensource@swarmauri.com
8
- Requires-Python: >=3.10,<3.13
9
- Classifier: License :: OSI Approved :: Apache Software License
10
- Classifier: Programming Language :: Python :: 3.10
11
- Classifier: Programming Language :: Python :: 3.11
12
- Classifier: Programming Language :: Python :: 3.12
13
- Provides-Extra: docs
14
- Provides-Extra: perf
15
- Requires-Dist: boto3 (>=1.28.0)
16
- Requires-Dist: cryptography
17
- Requires-Dist: mkdocs ; extra == "docs"
18
- Requires-Dist: pytest-benchmark (>=4.0.0) ; extra == "perf"
19
- Requires-Dist: swarmauri_base
20
- Requires-Dist: swarmauri_core
21
- Requires-Dist: swarmauri_standard
22
- Description-Content-Type: text/markdown
23
-
24
- # Swarmauri AWS KMS Key Provider
25
-
26
- Community plugin providing an AWS KMS backed `KeyProvider` for Swarmauri.
27
-
28
- ## Features
29
- - Manage RSA and AES keys via AWS KMS
30
- - Publish JWKs following [RFC 7517](https://datatracker.ietf.org/doc/html/rfc7517)
31
- - Generate cryptographically secure random bytes
32
-
33
- ## Installation
34
- ```bash
35
- pip install swarmauri_keyprovider_aws_kms
36
- ```
37
-
38
- ## Usage
39
- ```python
40
- from swarmauri_keyprovider_aws_kms import AwsKmsKeyProvider
41
-
42
- provider = AwsKmsKeyProvider(region="us-east-1")
43
- ```
44
-
@@ -1,20 +0,0 @@
1
- # Swarmauri AWS KMS Key Provider
2
-
3
- Community plugin providing an AWS KMS backed `KeyProvider` for Swarmauri.
4
-
5
- ## Features
6
- - Manage RSA and AES keys via AWS KMS
7
- - Publish JWKs following [RFC 7517](https://datatracker.ietf.org/doc/html/rfc7517)
8
- - Generate cryptographically secure random bytes
9
-
10
- ## Installation
11
- ```bash
12
- pip install swarmauri_keyprovider_aws_kms
13
- ```
14
-
15
- ## Usage
16
- ```python
17
- from swarmauri_keyprovider_aws_kms import AwsKmsKeyProvider
18
-
19
- provider = AwsKmsKeyProvider(region="us-east-1")
20
- ```