cora-vault 0.1.0__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.
- cora_vault-0.1.0/LICENSE +21 -0
- cora_vault-0.1.0/PKG-INFO +54 -0
- cora_vault-0.1.0/README.md +29 -0
- cora_vault-0.1.0/pyproject.toml +34 -0
- cora_vault-0.1.0/setup.cfg +4 -0
- cora_vault-0.1.0/src/cora_vault/__init__.py +6 -0
- cora_vault-0.1.0/src/cora_vault/client.py +70 -0
- cora_vault-0.1.0/src/cora_vault.egg-info/PKG-INFO +54 -0
- cora_vault-0.1.0/src/cora_vault.egg-info/SOURCES.txt +9 -0
- cora_vault-0.1.0/src/cora_vault.egg-info/dependency_links.txt +1 -0
- cora_vault-0.1.0/src/cora_vault.egg-info/top_level.txt +1 -0
cora_vault-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mentor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cora-vault
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Minimal Python client for Cora Vault secret engines
|
|
5
|
+
Author: mentor
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/kenmentor/cora-vault
|
|
8
|
+
Project-URL: Repository, https://github.com/kenmentor/cora-vault
|
|
9
|
+
Keywords: vault,secrets,key-management,devops
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Security
|
|
20
|
+
Classifier: Topic :: System :: Systems Administration
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# cora-vault-client
|
|
27
|
+
|
|
28
|
+
Minimal Python client for [Cora Vault](https://github.com/kenmentor/cora-vault)
|
|
29
|
+
secret engines. Stdlib only — no dependencies.
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install cora-vault-client
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Use
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
import os
|
|
41
|
+
from cora_vault import Vault
|
|
42
|
+
|
|
43
|
+
vault = Vault(endpoint="http://localhost:3000") # https in production
|
|
44
|
+
secret = vault.load_cluster("shop/prod", api_key="cv_...")
|
|
45
|
+
print(secret["token_value"]) # or os.environ["TOKEN_VALUE"]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`load_cluster` returns `{"token_value", "label", "cluster", "expires_at"}`
|
|
49
|
+
and mirrors the fields into `os.environ` (upper-cased) for drop-in config
|
|
50
|
+
use. Raises `VaultError` with a plain-English reason on 401/403/404/429.
|
|
51
|
+
|
|
52
|
+
Generate the per-engine API key in the vault dashboard
|
|
53
|
+
(engine → Settings → API keys). Service keys are presented as the
|
|
54
|
+
`x-api-key` header.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# cora-vault-client
|
|
2
|
+
|
|
3
|
+
Minimal Python client for [Cora Vault](https://github.com/kenmentor/cora-vault)
|
|
4
|
+
secret engines. Stdlib only — no dependencies.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pip install cora-vault-client
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Use
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
import os
|
|
16
|
+
from cora_vault import Vault
|
|
17
|
+
|
|
18
|
+
vault = Vault(endpoint="http://localhost:3000") # https in production
|
|
19
|
+
secret = vault.load_cluster("shop/prod", api_key="cv_...")
|
|
20
|
+
print(secret["token_value"]) # or os.environ["TOKEN_VALUE"]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`load_cluster` returns `{"token_value", "label", "cluster", "expires_at"}`
|
|
24
|
+
and mirrors the fields into `os.environ` (upper-cased) for drop-in config
|
|
25
|
+
use. Raises `VaultError` with a plain-English reason on 401/403/404/429.
|
|
26
|
+
|
|
27
|
+
Generate the per-engine API key in the vault dashboard
|
|
28
|
+
(engine → Settings → API keys). Service keys are presented as the
|
|
29
|
+
`x-api-key` header.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cora-vault"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Minimal Python client for Cora Vault secret engines"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "mentor" }]
|
|
13
|
+
keywords = ["vault", "secrets", "key-management", "devops"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Security",
|
|
25
|
+
"Topic :: System :: Systems Administration",
|
|
26
|
+
]
|
|
27
|
+
dependencies = []
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/kenmentor/cora-vault"
|
|
31
|
+
Repository = "https://github.com/kenmentor/cora-vault"
|
|
32
|
+
|
|
33
|
+
[tool.setuptools.packages.find]
|
|
34
|
+
where = ["src"]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import ssl
|
|
4
|
+
import urllib.error
|
|
5
|
+
import urllib.parse
|
|
6
|
+
import urllib.request
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class VaultError(RuntimeError):
|
|
10
|
+
"""Base exception for Vault operations."""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Vault:
|
|
14
|
+
def __init__(self, endpoint: str = "http://localhost:3000", verify_ssl: bool = True) -> None:
|
|
15
|
+
self.endpoint = endpoint.rstrip("/")
|
|
16
|
+
self.verify_ssl = verify_ssl
|
|
17
|
+
|
|
18
|
+
def _get_ssl_context(self) -> ssl.SSLContext:
|
|
19
|
+
if not self.verify_ssl:
|
|
20
|
+
ctx = ssl.create_default_context()
|
|
21
|
+
ctx.check_hostname = False
|
|
22
|
+
ctx.verify_mode = ssl.CERT_NONE
|
|
23
|
+
return ctx
|
|
24
|
+
return ssl.create_default_context()
|
|
25
|
+
|
|
26
|
+
def load_cluster(self, vault_cluster: str, api_key: str | None = None) -> dict[str, str]:
|
|
27
|
+
"""Fetch the active secret for a cluster.
|
|
28
|
+
|
|
29
|
+
Returns {"token_value": ..., "label": ..., ...} and mirrors the
|
|
30
|
+
fields into os.environ (upper-cased) for drop-in config use.
|
|
31
|
+
"""
|
|
32
|
+
url = f"{self.endpoint}/api/embed/{urllib.parse.quote(vault_cluster, safe='')}"
|
|
33
|
+
|
|
34
|
+
headers = {}
|
|
35
|
+
if api_key:
|
|
36
|
+
headers["x-api-key"] = api_key
|
|
37
|
+
|
|
38
|
+
req = urllib.request.Request(url, headers=headers)
|
|
39
|
+
|
|
40
|
+
try:
|
|
41
|
+
context = self._get_ssl_context()
|
|
42
|
+
with urllib.request.urlopen(req, timeout=10, context=context) as res:
|
|
43
|
+
data = json.load(res)
|
|
44
|
+
except urllib.error.HTTPError as e:
|
|
45
|
+
try:
|
|
46
|
+
detail = json.load(e).get("error", "")
|
|
47
|
+
except Exception:
|
|
48
|
+
detail = ""
|
|
49
|
+
|
|
50
|
+
if e.code == 401:
|
|
51
|
+
raise VaultError("missing service key (set VAULT_API_KEY)") from None
|
|
52
|
+
if e.code == 403:
|
|
53
|
+
raise VaultError(f"forbidden: {detail or 'key rejected / IP not allowlisted'}") from None
|
|
54
|
+
if e.code == 404:
|
|
55
|
+
raise VaultError(f'no active secret for "{vault_cluster}"') from None
|
|
56
|
+
if e.code == 429:
|
|
57
|
+
raise VaultError("rate limited — back off and retry") from None
|
|
58
|
+
raise VaultError(f"unexpected status {e.code}: {detail}") from None
|
|
59
|
+
except urllib.error.URLError as e:
|
|
60
|
+
raise VaultError(f"failed to reach Vault server: {e.reason}") from None
|
|
61
|
+
|
|
62
|
+
injected: dict[str, str] = {}
|
|
63
|
+
if isinstance(data, dict):
|
|
64
|
+
for key, value in data.items():
|
|
65
|
+
if value is not None:
|
|
66
|
+
env_key = str(key).upper()
|
|
67
|
+
env_val = str(value)
|
|
68
|
+
os.environ[env_key] = env_val
|
|
69
|
+
injected[str(key)] = env_val
|
|
70
|
+
return injected
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cora-vault
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Minimal Python client for Cora Vault secret engines
|
|
5
|
+
Author: mentor
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/kenmentor/cora-vault
|
|
8
|
+
Project-URL: Repository, https://github.com/kenmentor/cora-vault
|
|
9
|
+
Keywords: vault,secrets,key-management,devops
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Security
|
|
20
|
+
Classifier: Topic :: System :: Systems Administration
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# cora-vault-client
|
|
27
|
+
|
|
28
|
+
Minimal Python client for [Cora Vault](https://github.com/kenmentor/cora-vault)
|
|
29
|
+
secret engines. Stdlib only — no dependencies.
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install cora-vault-client
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Use
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
import os
|
|
41
|
+
from cora_vault import Vault
|
|
42
|
+
|
|
43
|
+
vault = Vault(endpoint="http://localhost:3000") # https in production
|
|
44
|
+
secret = vault.load_cluster("shop/prod", api_key="cv_...")
|
|
45
|
+
print(secret["token_value"]) # or os.environ["TOKEN_VALUE"]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`load_cluster` returns `{"token_value", "label", "cluster", "expires_at"}`
|
|
49
|
+
and mirrors the fields into `os.environ` (upper-cased) for drop-in config
|
|
50
|
+
use. Raises `VaultError` with a plain-English reason on 401/403/404/429.
|
|
51
|
+
|
|
52
|
+
Generate the per-engine API key in the vault dashboard
|
|
53
|
+
(engine → Settings → API keys). Service keys are presented as the
|
|
54
|
+
`x-api-key` header.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cora_vault
|