dworshak-access 0.1.4__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,7 @@
1
+ Copyright 2026 George Clayton Bennett <https://github.com/City-of-Memphis-Wastewater/dworshak-access/>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: dworshak-access
3
+ Version: 0.1.4
4
+ Summary: **dworshak-access** is a lightweight library. It exposes the **get_secrets()** function, to allow a program to leverage credentials that have been established using the Drowshak CLI tool, which is a separate package.
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: cryptography>=46.0.3
9
+ Dynamic: license-file
10
+
11
+ **dworshak-access** is a lightweight library.
12
+
13
+ ## Purpose
14
+ Allow a program to leverage credentials that have been established using the Drowshak CLI tool, which is a separate package.
15
+
16
+ ## Functions exposed in **dworshak-access**:
17
+ - check_vault() # For troubleshooting automated testing.
18
+ - get_credential() # The meat and potatoes.
19
+
20
+
21
+ ### Example
22
+
23
+ ```python
24
+ from dworshak_access import get_credential
25
+
26
+ service_name = "MyThirdFavoriteAPI"
27
+ item_id_u = "username"
28
+ item_id_p = "password"
29
+
30
+ user = get_credential(service_name,item_id_u)
31
+ pass = get_credential(service_name,item_id_p)
32
+
33
+ # Then use these in your program
34
+
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Cryptography Library
40
+
41
+ The only external Python library used is crytography, for the Fernet class.
42
+
43
+ On a Termux system, cryptography can be built from source if the user first installs Rust with `pkg install rust`.
44
+ Is `uv sync` better at accomplishing this, due to the rust packagig location? Argue and let me know.
45
+ Alteratively, a Termux user can run `pkg install python-crytophy`, then build a fresh venv folder using the --system-site-packages flag to include the now system-wide crytography package. Or maybe you don't need a venv at all. Hm.
@@ -0,0 +1,35 @@
1
+ **dworshak-access** is a lightweight library.
2
+
3
+ ## Purpose
4
+ Allow a program to leverage credentials that have been established using the Drowshak CLI tool, which is a separate package.
5
+
6
+ ## Functions exposed in **dworshak-access**:
7
+ - check_vault() # For troubleshooting automated testing.
8
+ - get_credential() # The meat and potatoes.
9
+
10
+
11
+ ### Example
12
+
13
+ ```python
14
+ from dworshak_access import get_credential
15
+
16
+ service_name = "MyThirdFavoriteAPI"
17
+ item_id_u = "username"
18
+ item_id_p = "password"
19
+
20
+ user = get_credential(service_name,item_id_u)
21
+ pass = get_credential(service_name,item_id_p)
22
+
23
+ # Then use these in your program
24
+
25
+ ```
26
+
27
+ ---
28
+
29
+ ## Cryptography Library
30
+
31
+ The only external Python library used is crytography, for the Fernet class.
32
+
33
+ On a Termux system, cryptography can be built from source if the user first installs Rust with `pkg install rust`.
34
+ Is `uv sync` better at accomplishing this, due to the rust packagig location? Argue and let me know.
35
+ Alteratively, a Termux user can run `pkg install python-crytophy`, then build a fresh venv folder using the --system-site-packages flag to include the now system-wide crytography package. Or maybe you don't need a venv at all. Hm.
@@ -0,0 +1,19 @@
1
+ [project]
2
+ name = "dworshak-access"
3
+ version = "0.1.4"
4
+ description = "**dworshak-access** is a lightweight library. It exposes the **get_secrets()** function, to allow a program to leverage credentials that have been established using the Drowshak CLI tool, which is a separate package."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ dependencies = [
8
+ "cryptography>=46.0.3",
9
+ ]
10
+
11
+ [tool.uv]
12
+ # This tells uv that if it can't find a wheel for aarch64,
13
+ # it is allowed to build from source using your local Rust/Clang.
14
+ package = true
15
+ resolution = "highest"
16
+
17
+ [build-system]
18
+ requires = ["setuptools>=64", "wheel"]
19
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,9 @@
1
+ # src/dowrshak_access/__init__.py
2
+
3
+ from dworshak_access.vault import get_secret, check_vault
4
+
5
+ __all__ = [
6
+ "get_secret",
7
+ "check_vault"
8
+ ]
9
+
@@ -0,0 +1,52 @@
1
+ # src/dworshak-access/vault.py
2
+ import sqlite3
3
+ import os
4
+ from pathlib import Path
5
+ from typing import NamedTuple, List, Tuple, Optional
6
+ from cryptography.fernet import Fernet
7
+
8
+ DEFAULT_ROOT = Path.home() / ".dworshak"
9
+
10
+ class VaultStatus(NamedTuple):
11
+ is_valid: bool
12
+ message: str
13
+ root_path: Path
14
+
15
+ def check_vault(root: Path = DEFAULT_ROOT) -> VaultStatus:
16
+ """Diagnose the health of the Dworshak environment."""
17
+ if not root.exists():
18
+ return VaultStatus(False, "Vault directory does not exist.", root)
19
+ if not (root / ".key").exists():
20
+ return VaultStatus(False, "Security key (.key) is missing.", root)
21
+ if not (root / "vault.db").exists():
22
+ return VaultStatus(False, "Credential database (vault.db) is missing.", root)
23
+
24
+ try:
25
+ with sqlite3.connect(root / "vault.db") as conn:
26
+ conn.execute("SELECT 1 FROM credentials LIMIT 1")
27
+ except sqlite3.Error as e:
28
+ return VaultStatus(False, f"Database error: {e}", root)
29
+
30
+ return VaultStatus(True, "Vault is healthy.", root)
31
+
32
+ def get_secret(service: str, item: str, root: Path = DEFAULT_ROOT) -> str:
33
+ """Retrieve and decrypt a specific secret."""
34
+ key_path = root / ".key"
35
+ db_path = root / "vault.db"
36
+
37
+ if not key_path.exists():
38
+ raise FileNotFoundError(f"Dworshak key not found at {key_path}")
39
+
40
+ fernet = Fernet(key_path.read_bytes())
41
+
42
+ with sqlite3.connect(db_path) as conn:
43
+ cursor = conn.execute(
44
+ "SELECT secret FROM credentials WHERE service = ? AND item = ?",
45
+ (service, item)
46
+ )
47
+ row = cursor.fetchone()
48
+
49
+ if not row:
50
+ raise KeyError(f"No credential found for {service}/{item}")
51
+
52
+ return fernet.decrypt(row[0]).decode()
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: dworshak-access
3
+ Version: 0.1.4
4
+ Summary: **dworshak-access** is a lightweight library. It exposes the **get_secrets()** function, to allow a program to leverage credentials that have been established using the Drowshak CLI tool, which is a separate package.
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: cryptography>=46.0.3
9
+ Dynamic: license-file
10
+
11
+ **dworshak-access** is a lightweight library.
12
+
13
+ ## Purpose
14
+ Allow a program to leverage credentials that have been established using the Drowshak CLI tool, which is a separate package.
15
+
16
+ ## Functions exposed in **dworshak-access**:
17
+ - check_vault() # For troubleshooting automated testing.
18
+ - get_credential() # The meat and potatoes.
19
+
20
+
21
+ ### Example
22
+
23
+ ```python
24
+ from dworshak_access import get_credential
25
+
26
+ service_name = "MyThirdFavoriteAPI"
27
+ item_id_u = "username"
28
+ item_id_p = "password"
29
+
30
+ user = get_credential(service_name,item_id_u)
31
+ pass = get_credential(service_name,item_id_p)
32
+
33
+ # Then use these in your program
34
+
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Cryptography Library
40
+
41
+ The only external Python library used is crytography, for the Fernet class.
42
+
43
+ On a Termux system, cryptography can be built from source if the user first installs Rust with `pkg install rust`.
44
+ Is `uv sync` better at accomplishing this, due to the rust packagig location? Argue and let me know.
45
+ Alteratively, a Termux user can run `pkg install python-crytophy`, then build a fresh venv folder using the --system-site-packages flag to include the now system-wide crytography package. Or maybe you don't need a venv at all. Hm.
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/dworshak_access/__init__.py
5
+ src/dworshak_access/vault.py
6
+ src/dworshak_access.egg-info/PKG-INFO
7
+ src/dworshak_access.egg-info/SOURCES.txt
8
+ src/dworshak_access.egg-info/dependency_links.txt
9
+ src/dworshak_access.egg-info/requires.txt
10
+ src/dworshak_access.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ cryptography>=46.0.3
@@ -0,0 +1 @@
1
+ dworshak_access