swarmauri_keyprovider_ssh 0.3.0.dev3__tar.gz → 0.3.0.dev31__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.
- swarmauri_keyprovider_ssh-0.3.0.dev31/PKG-INFO +130 -0
- swarmauri_keyprovider_ssh-0.3.0.dev31/README.md +103 -0
- {swarmauri_keyprovider_ssh-0.3.0.dev3 → swarmauri_keyprovider_ssh-0.3.0.dev31}/pyproject.toml +13 -2
- {swarmauri_keyprovider_ssh-0.3.0.dev3 → swarmauri_keyprovider_ssh-0.3.0.dev31}/swarmauri_keyprovider_ssh/SshKeyProvider.py +43 -3
- swarmauri_keyprovider_ssh-0.3.0.dev3/PKG-INFO +0 -76
- swarmauri_keyprovider_ssh-0.3.0.dev3/README.md +0 -53
- {swarmauri_keyprovider_ssh-0.3.0.dev3 → swarmauri_keyprovider_ssh-0.3.0.dev31}/LICENSE +0 -0
- {swarmauri_keyprovider_ssh-0.3.0.dev3 → swarmauri_keyprovider_ssh-0.3.0.dev31}/swarmauri_keyprovider_ssh/__init__.py +0 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: swarmauri_keyprovider_ssh
|
|
3
|
+
Version: 0.3.0.dev31
|
|
4
|
+
Summary: SSH-based key provider for Swarmauri
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: swarmauri,sdk,standards,keyprovider,ssh,key-management
|
|
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: Natural Language :: English
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Development Status :: 3 - Alpha
|
|
18
|
+
Classifier: Topic :: Security :: Cryptography
|
|
19
|
+
Classifier: Intended Audience :: Developers
|
|
20
|
+
Classifier: Programming Language :: Python
|
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
|
22
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
23
|
+
Requires-Dist: cryptography
|
|
24
|
+
Requires-Dist: swarmauri_base
|
|
25
|
+
Requires-Dist: swarmauri_core
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_ssh/"><img src="https://img.shields.io/pypi/dm/swarmauri_keyprovider_ssh" alt="PyPI - Downloads"/></a>
|
|
32
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_keyprovider_ssh/"><img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_keyprovider_ssh.svg"/></a>
|
|
33
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_ssh/"><img src="https://img.shields.io/pypi/pyversions/swarmauri_keyprovider_ssh" alt="PyPI - Python Version"/></a>
|
|
34
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_ssh/"><img src="https://img.shields.io/pypi/l/swarmauri_keyprovider_ssh" alt="PyPI - License"/></a>
|
|
35
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_ssh/"><img src="https://img.shields.io/pypi/v/swarmauri_keyprovider_ssh?label=swarmauri_keyprovider_ssh&color=green" alt="PyPI - swarmauri_keyprovider_ssh"/></a>
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
# Swarmauri SSH Key Provider
|
|
39
|
+
|
|
40
|
+
An asynchronous `KeyProviderBase` implementation that keeps SSH key material in
|
|
41
|
+
memory and bridges it to Swarmauri's signing abstractions.
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
- Generate new Ed25519, RSA-PSS (SHA-256), or ECDSA P-256 key pairs on demand.
|
|
46
|
+
- Import existing private keys (PEM) or public keys (OpenSSH) while respecting
|
|
47
|
+
each key's `ExportPolicy`.
|
|
48
|
+
- Rotate keys, enumerate versions, and optionally destroy specific versions or
|
|
49
|
+
entire key identifiers.
|
|
50
|
+
- Export public keys as RFC 7517-compliant JWKs/JWKS with OpenSSH fingerprints
|
|
51
|
+
embedded in the `tags` metadata.
|
|
52
|
+
- Produce random bytes and derive keying material using the HKDF construction
|
|
53
|
+
(RFC 5869).
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
Choose the tool that matches your workflow:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# pip
|
|
61
|
+
pip install swarmauri_keyprovider_ssh
|
|
62
|
+
|
|
63
|
+
# Poetry
|
|
64
|
+
poetry add swarmauri_keyprovider_ssh
|
|
65
|
+
|
|
66
|
+
# uv
|
|
67
|
+
uv add swarmauri_keyprovider_ssh
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
|
|
72
|
+
The provider exposes an asynchronous interface for creating and managing
|
|
73
|
+
SSH-based signing keys. The snippet below creates a new Ed25519 key and
|
|
74
|
+
exports its public component as a JSON Web Key (JWK):
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
import asyncio
|
|
78
|
+
from swarmauri_keyprovider_ssh import SshKeyProvider
|
|
79
|
+
from swarmauri_core.key_providers.types import (
|
|
80
|
+
KeySpec,
|
|
81
|
+
KeyAlg,
|
|
82
|
+
KeyClass,
|
|
83
|
+
ExportPolicy,
|
|
84
|
+
KeyUse,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
async def main() -> None:
|
|
89
|
+
provider = SshKeyProvider()
|
|
90
|
+
spec = KeySpec(
|
|
91
|
+
klass=KeyClass.asymmetric,
|
|
92
|
+
alg=KeyAlg.ED25519,
|
|
93
|
+
uses=(KeyUse.SIGN, KeyUse.VERIFY),
|
|
94
|
+
export_policy=ExportPolicy.PUBLIC_ONLY,
|
|
95
|
+
)
|
|
96
|
+
ref = await provider.create_key(spec)
|
|
97
|
+
jwk = await provider.get_public_jwk(ref.kid)
|
|
98
|
+
print(jwk)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
asyncio.run(main())
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Keys can also be rotated, and the provider will track key versions:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
ref = await provider.create_key(spec)
|
|
108
|
+
await provider.rotate_key(ref.kid)
|
|
109
|
+
assert await provider.list_versions(ref.kid) == (1, 2)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Use `destroy_key()` to remove an entire key identifier or just a single
|
|
113
|
+
version, and `jwks(prefix_kids=...)` when you need to emit a filtered JWKS for
|
|
114
|
+
downstream consumers.
|
|
115
|
+
|
|
116
|
+
Existing keys can be imported from PEM or OpenSSH data and exposed via JWKS:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from pathlib import Path
|
|
120
|
+
|
|
121
|
+
pem = Path("id_ed25519").read_bytes()
|
|
122
|
+
ref = await provider.import_key(spec, pem)
|
|
123
|
+
jwks = await provider.jwks()
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Want to help?
|
|
127
|
+
|
|
128
|
+
If you want to contribute to swarmauri-sdk, read up on our
|
|
129
|
+
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
130
|
+
that will help you get started.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_ssh/"><img src="https://img.shields.io/pypi/dm/swarmauri_keyprovider_ssh" alt="PyPI - Downloads"/></a>
|
|
5
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_keyprovider_ssh/"><img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_keyprovider_ssh.svg"/></a>
|
|
6
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_ssh/"><img src="https://img.shields.io/pypi/pyversions/swarmauri_keyprovider_ssh" alt="PyPI - Python Version"/></a>
|
|
7
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_ssh/"><img src="https://img.shields.io/pypi/l/swarmauri_keyprovider_ssh" alt="PyPI - License"/></a>
|
|
8
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_ssh/"><img src="https://img.shields.io/pypi/v/swarmauri_keyprovider_ssh?label=swarmauri_keyprovider_ssh&color=green" alt="PyPI - swarmauri_keyprovider_ssh"/></a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
# Swarmauri SSH Key Provider
|
|
12
|
+
|
|
13
|
+
An asynchronous `KeyProviderBase` implementation that keeps SSH key material in
|
|
14
|
+
memory and bridges it to Swarmauri's signing abstractions.
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- Generate new Ed25519, RSA-PSS (SHA-256), or ECDSA P-256 key pairs on demand.
|
|
19
|
+
- Import existing private keys (PEM) or public keys (OpenSSH) while respecting
|
|
20
|
+
each key's `ExportPolicy`.
|
|
21
|
+
- Rotate keys, enumerate versions, and optionally destroy specific versions or
|
|
22
|
+
entire key identifiers.
|
|
23
|
+
- Export public keys as RFC 7517-compliant JWKs/JWKS with OpenSSH fingerprints
|
|
24
|
+
embedded in the `tags` metadata.
|
|
25
|
+
- Produce random bytes and derive keying material using the HKDF construction
|
|
26
|
+
(RFC 5869).
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
Choose the tool that matches your workflow:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# pip
|
|
34
|
+
pip install swarmauri_keyprovider_ssh
|
|
35
|
+
|
|
36
|
+
# Poetry
|
|
37
|
+
poetry add swarmauri_keyprovider_ssh
|
|
38
|
+
|
|
39
|
+
# uv
|
|
40
|
+
uv add swarmauri_keyprovider_ssh
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
The provider exposes an asynchronous interface for creating and managing
|
|
46
|
+
SSH-based signing keys. The snippet below creates a new Ed25519 key and
|
|
47
|
+
exports its public component as a JSON Web Key (JWK):
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
import asyncio
|
|
51
|
+
from swarmauri_keyprovider_ssh import SshKeyProvider
|
|
52
|
+
from swarmauri_core.key_providers.types import (
|
|
53
|
+
KeySpec,
|
|
54
|
+
KeyAlg,
|
|
55
|
+
KeyClass,
|
|
56
|
+
ExportPolicy,
|
|
57
|
+
KeyUse,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
async def main() -> None:
|
|
62
|
+
provider = SshKeyProvider()
|
|
63
|
+
spec = KeySpec(
|
|
64
|
+
klass=KeyClass.asymmetric,
|
|
65
|
+
alg=KeyAlg.ED25519,
|
|
66
|
+
uses=(KeyUse.SIGN, KeyUse.VERIFY),
|
|
67
|
+
export_policy=ExportPolicy.PUBLIC_ONLY,
|
|
68
|
+
)
|
|
69
|
+
ref = await provider.create_key(spec)
|
|
70
|
+
jwk = await provider.get_public_jwk(ref.kid)
|
|
71
|
+
print(jwk)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
asyncio.run(main())
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Keys can also be rotated, and the provider will track key versions:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
ref = await provider.create_key(spec)
|
|
81
|
+
await provider.rotate_key(ref.kid)
|
|
82
|
+
assert await provider.list_versions(ref.kid) == (1, 2)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Use `destroy_key()` to remove an entire key identifier or just a single
|
|
86
|
+
version, and `jwks(prefix_kids=...)` when you need to emit a filtered JWKS for
|
|
87
|
+
downstream consumers.
|
|
88
|
+
|
|
89
|
+
Existing keys can be imported from PEM or OpenSSH data and exposed via JWKS:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from pathlib import Path
|
|
93
|
+
|
|
94
|
+
pem = Path("id_ed25519").read_bytes()
|
|
95
|
+
ref = await provider.import_key(spec, pem)
|
|
96
|
+
jwks = await provider.jwks()
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Want to help?
|
|
100
|
+
|
|
101
|
+
If you want to contribute to swarmauri-sdk, read up on our
|
|
102
|
+
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
103
|
+
that will help you get started.
|
{swarmauri_keyprovider_ssh-0.3.0.dev3 → swarmauri_keyprovider_ssh-0.3.0.dev31}/pyproject.toml
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "swarmauri_keyprovider_ssh"
|
|
3
|
-
version = "0.3.0.
|
|
3
|
+
version = "0.3.0.dev31"
|
|
4
4
|
description = "SSH-based key provider for Swarmauri"
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
requires-python = ">=3.10,<3.13"
|
|
8
|
-
authors = [{ name = "
|
|
8
|
+
authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
|
|
9
9
|
classifiers = [
|
|
10
10
|
"License :: OSI Approved :: Apache Software License",
|
|
11
11
|
"Natural Language :: English",
|
|
@@ -16,12 +16,23 @@ classifiers = [
|
|
|
16
16
|
"Development Status :: 3 - Alpha",
|
|
17
17
|
"Topic :: Security :: Cryptography",
|
|
18
18
|
"Intended Audience :: Developers",
|
|
19
|
+
"Programming Language :: Python",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
19
22
|
]
|
|
20
23
|
dependencies = [
|
|
21
24
|
"swarmauri_core",
|
|
22
25
|
"swarmauri_base",
|
|
23
26
|
"cryptography",
|
|
24
27
|
]
|
|
28
|
+
keywords = [
|
|
29
|
+
'swarmauri',
|
|
30
|
+
'sdk',
|
|
31
|
+
'standards',
|
|
32
|
+
'keyprovider',
|
|
33
|
+
'ssh',
|
|
34
|
+
'key-management',
|
|
35
|
+
]
|
|
25
36
|
|
|
26
37
|
[tool.uv.sources]
|
|
27
38
|
swarmauri_core = { workspace = true }
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
"""Utilities for managing SSH keys with JWK/JWKS support.
|
|
2
|
+
|
|
3
|
+
Provides :class:`SshKeyProvider` for generating, importing and rotating
|
|
4
|
+
SSH-based keys.
|
|
5
|
+
"""
|
|
6
|
+
|
|
1
7
|
from __future__ import annotations
|
|
2
8
|
|
|
3
9
|
import base64
|
|
@@ -16,24 +22,48 @@ from cryptography.hazmat.primitives.serialization import (
|
|
|
16
22
|
PublicFormat,
|
|
17
23
|
)
|
|
18
24
|
|
|
19
|
-
from swarmauri_base.
|
|
20
|
-
from swarmauri_core.
|
|
25
|
+
from swarmauri_base.key_providers.KeyProviderBase import KeyProviderBase
|
|
26
|
+
from swarmauri_core.key_providers.types import KeySpec, KeyAlg, KeyClass, ExportPolicy
|
|
21
27
|
from swarmauri_core.crypto.types import KeyRef
|
|
22
28
|
|
|
23
29
|
|
|
24
30
|
def _b64u(b: bytes) -> str:
|
|
31
|
+
"""URL-safe base64 encoding without padding.
|
|
32
|
+
|
|
33
|
+
b (bytes): Data to encode.
|
|
34
|
+
RETURNS (str): Encoded string.
|
|
35
|
+
"""
|
|
36
|
+
|
|
25
37
|
return base64.urlsafe_b64encode(b).rstrip(b"=").decode("ascii")
|
|
26
38
|
|
|
27
39
|
|
|
28
40
|
def _ssh_pub_bytes(pub) -> bytes:
|
|
41
|
+
"""Serialize a public key in OpenSSH format.
|
|
42
|
+
|
|
43
|
+
pub: Public key object.
|
|
44
|
+
RETURNS (bytes): OpenSSH-formatted bytes.
|
|
45
|
+
"""
|
|
46
|
+
|
|
29
47
|
return pub.public_bytes(Encoding.OpenSSH, PublicFormat.OpenSSH)
|
|
30
48
|
|
|
31
49
|
|
|
32
50
|
def _pem_priv(priv) -> bytes:
|
|
51
|
+
"""Serialize a private key in unencrypted PEM format.
|
|
52
|
+
|
|
53
|
+
priv: Private key object.
|
|
54
|
+
RETURNS (bytes): PKCS#8 encoded PEM bytes.
|
|
55
|
+
"""
|
|
56
|
+
|
|
33
57
|
return priv.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, NoEncryption())
|
|
34
58
|
|
|
35
59
|
|
|
36
60
|
def _fingerprint(ssh_pub: bytes) -> str:
|
|
61
|
+
"""Compute an MD5 fingerprint for an OpenSSH public key.
|
|
62
|
+
|
|
63
|
+
ssh_pub (bytes): Public key in OpenSSH format.
|
|
64
|
+
RETURNS (str): Hexadecimal fingerprint or ``"unknown"``.
|
|
65
|
+
"""
|
|
66
|
+
|
|
37
67
|
try:
|
|
38
68
|
b64 = ssh_pub.split(None, 2)[1]
|
|
39
69
|
blob = base64.b64decode(b64)
|
|
@@ -44,7 +74,17 @@ def _fingerprint(ssh_pub: bytes) -> str:
|
|
|
44
74
|
|
|
45
75
|
|
|
46
76
|
class SshKeyProvider(KeyProviderBase):
|
|
47
|
-
"""SSH
|
|
77
|
+
"""Manage SSH keys and expose them as JWK or JWKS documents.
|
|
78
|
+
|
|
79
|
+
create_key(spec) -> KeyRef:
|
|
80
|
+
Generate a new key pair according to ``spec``.
|
|
81
|
+
import_key(spec, material, public=None) -> KeyRef:
|
|
82
|
+
Register an existing key from PEM or OpenSSH data.
|
|
83
|
+
rotate_key(kid, spec_overrides=None) -> KeyRef:
|
|
84
|
+
Create a new version for the given ``kid``.
|
|
85
|
+
jwks(prefix_kids=None) -> dict:
|
|
86
|
+
Return all managed keys as a JWKS structure.
|
|
87
|
+
"""
|
|
48
88
|
|
|
49
89
|
type: Literal["SshKeyProvider"] = "SshKeyProvider"
|
|
50
90
|
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: swarmauri_keyprovider_ssh
|
|
3
|
-
Version: 0.3.0.dev3
|
|
4
|
-
Summary: SSH-based key provider 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: Natural Language :: English
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
-
Classifier: Development Status :: 3 - Alpha
|
|
16
|
-
Classifier: Topic :: Security :: Cryptography
|
|
17
|
-
Classifier: Intended Audience :: Developers
|
|
18
|
-
Requires-Dist: cryptography
|
|
19
|
-
Requires-Dist: swarmauri_base
|
|
20
|
-
Requires-Dist: swarmauri_core
|
|
21
|
-
Description-Content-Type: text/markdown
|
|
22
|
-
|
|
23
|
-

|
|
24
|
-
|
|
25
|
-
# Swarmauri SSH Key Provider
|
|
26
|
-
|
|
27
|
-
Interfaces with local SSH keys to generate and manage signing keys.
|
|
28
|
-
|
|
29
|
-
## Installation
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
pip install swarmauri_keyprovider_ssh
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Usage
|
|
36
|
-
|
|
37
|
-
The provider exposes an asynchronous interface for creating and managing
|
|
38
|
-
SSH-based signing keys. The snippet below creates a new Ed25519 key and
|
|
39
|
-
exports its public component as a JSON Web Key (JWK):
|
|
40
|
-
|
|
41
|
-
```python
|
|
42
|
-
import asyncio
|
|
43
|
-
from swarmauri_keyprovider_ssh import SshKeyProvider
|
|
44
|
-
from swarmauri_core.keys.types import (
|
|
45
|
-
KeySpec,
|
|
46
|
-
KeyAlg,
|
|
47
|
-
KeyClass,
|
|
48
|
-
ExportPolicy,
|
|
49
|
-
KeyUse,
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
async def main() -> None:
|
|
54
|
-
provider = SshKeyProvider()
|
|
55
|
-
spec = KeySpec(
|
|
56
|
-
klass=KeyClass.asymmetric,
|
|
57
|
-
alg=KeyAlg.ED25519,
|
|
58
|
-
uses=(KeyUse.SIGN, KeyUse.VERIFY),
|
|
59
|
-
export_policy=ExportPolicy.PUBLIC_ONLY,
|
|
60
|
-
)
|
|
61
|
-
ref = await provider.create_key(spec)
|
|
62
|
-
jwk = await provider.get_public_jwk(ref.kid)
|
|
63
|
-
print(jwk)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
asyncio.run(main())
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Keys can also be rotated, and the provider will track key versions:
|
|
70
|
-
|
|
71
|
-
```python
|
|
72
|
-
ref = await provider.create_key(spec)
|
|
73
|
-
await provider.rotate_key(ref.kid)
|
|
74
|
-
assert await provider.list_versions(ref.kid) == (1, 2)
|
|
75
|
-
```
|
|
76
|
-
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
|
-
# Swarmauri SSH Key Provider
|
|
4
|
-
|
|
5
|
-
Interfaces with local SSH keys to generate and manage signing keys.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
pip install swarmauri_keyprovider_ssh
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
The provider exposes an asynchronous interface for creating and managing
|
|
16
|
-
SSH-based signing keys. The snippet below creates a new Ed25519 key and
|
|
17
|
-
exports its public component as a JSON Web Key (JWK):
|
|
18
|
-
|
|
19
|
-
```python
|
|
20
|
-
import asyncio
|
|
21
|
-
from swarmauri_keyprovider_ssh import SshKeyProvider
|
|
22
|
-
from swarmauri_core.keys.types import (
|
|
23
|
-
KeySpec,
|
|
24
|
-
KeyAlg,
|
|
25
|
-
KeyClass,
|
|
26
|
-
ExportPolicy,
|
|
27
|
-
KeyUse,
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
async def main() -> None:
|
|
32
|
-
provider = SshKeyProvider()
|
|
33
|
-
spec = KeySpec(
|
|
34
|
-
klass=KeyClass.asymmetric,
|
|
35
|
-
alg=KeyAlg.ED25519,
|
|
36
|
-
uses=(KeyUse.SIGN, KeyUse.VERIFY),
|
|
37
|
-
export_policy=ExportPolicy.PUBLIC_ONLY,
|
|
38
|
-
)
|
|
39
|
-
ref = await provider.create_key(spec)
|
|
40
|
-
jwk = await provider.get_public_jwk(ref.kid)
|
|
41
|
-
print(jwk)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
asyncio.run(main())
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Keys can also be rotated, and the provider will track key versions:
|
|
48
|
-
|
|
49
|
-
```python
|
|
50
|
-
ref = await provider.create_key(spec)
|
|
51
|
-
await provider.rotate_key(ref.kid)
|
|
52
|
-
assert await provider.list_versions(ref.kid) == (1, 2)
|
|
53
|
-
```
|
|
File without changes
|
|
File without changes
|