dworshak-access 0.1.11__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.

Potentially problematic release.


This version of dworshak-access might be problematic. Click here for more details.

@@ -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,64 @@
1
+ Metadata-Version: 2.4
2
+ Name: dworshak-access
3
+ Version: 0.1.11
4
+ Summary: **dworshak-access** is a light-weight library for local credential access. It exposes the **get_secret()** 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.9
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 light-weight library for local credential access. By adding **dworshak-access** as a dependency to your Python project, you enable your program or script to leverage credentials that have been established using the Drowshak CLI tool, which is a separate package.
12
+
13
+ ## Functions exposed in **dworshak-access**:
14
+ - check_vault() # For troubleshooting automated testing.
15
+ - get_secret() # The meat and potatoes.
16
+
17
+
18
+ ### Example
19
+
20
+ ```zsh
21
+ uv add dworshak-access
22
+ ```
23
+
24
+ ```python
25
+ from dworshak_access import get_secret
26
+
27
+ service_name = "MyThirdFavoriteAPI"
28
+ item_id_u = "username"
29
+ item_id_p = "password"
30
+
31
+ un = get_secret(service_name,item_id_u)
32
+ pw = get_secret(service_name,item_id_p)
33
+
34
+ # Then use these in your program
35
+
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Cryptography Library (When Building **dworshak-access** From Source or When Using It A Dependency in Your Project)
41
+
42
+ The only external Python library used is `crytography`, for the **Fernet** class.
43
+
44
+ On a Termux system, cryptography can **(A)** be built from source or **(B)** the precompiled python-crytography dedicated Termux package can be used.
45
+
46
+ #### A. Allow cryptography to build from source (uv is better at this compared to using pip)
47
+
48
+ ```zsh
49
+ pkg install rust binutils
50
+ uv sync
51
+ ```
52
+
53
+ #### B. Use python-cryptography (This is faster but pollutes your local venv with other system site packages.)
54
+
55
+ ```zsh
56
+ pkg install python-cryptography
57
+ uv venv --system-site-packages
58
+ uv sync
59
+ ```
60
+
61
+ `uv venv --system-site-packages` is a modern,faster alternative to `python -m venv .venv --system-site-packages`.
62
+ Because **uv** manages the build-time dependencies (**setuptools-rust** and **cffi**) in an isolated environment and coordinates the hand-off to the Rust compiler more robustly than **pip**, it is the recommended way to install **cryptography** from source on Termux.
63
+
64
+ ---
@@ -0,0 +1,54 @@
1
+ **dworshak-access** is a light-weight library for local credential access. By adding **dworshak-access** as a dependency to your Python project, you enable your program or script to leverage credentials that have been established using the Drowshak CLI tool, which is a separate package.
2
+
3
+ ## Functions exposed in **dworshak-access**:
4
+ - check_vault() # For troubleshooting automated testing.
5
+ - get_secret() # The meat and potatoes.
6
+
7
+
8
+ ### Example
9
+
10
+ ```zsh
11
+ uv add dworshak-access
12
+ ```
13
+
14
+ ```python
15
+ from dworshak_access import get_secret
16
+
17
+ service_name = "MyThirdFavoriteAPI"
18
+ item_id_u = "username"
19
+ item_id_p = "password"
20
+
21
+ un = get_secret(service_name,item_id_u)
22
+ pw = get_secret(service_name,item_id_p)
23
+
24
+ # Then use these in your program
25
+
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Cryptography Library (When Building **dworshak-access** From Source or When Using It A Dependency in Your Project)
31
+
32
+ The only external Python library used is `crytography`, for the **Fernet** class.
33
+
34
+ On a Termux system, cryptography can **(A)** be built from source or **(B)** the precompiled python-crytography dedicated Termux package can be used.
35
+
36
+ #### A. Allow cryptography to build from source (uv is better at this compared to using pip)
37
+
38
+ ```zsh
39
+ pkg install rust binutils
40
+ uv sync
41
+ ```
42
+
43
+ #### B. Use python-cryptography (This is faster but pollutes your local venv with other system site packages.)
44
+
45
+ ```zsh
46
+ pkg install python-cryptography
47
+ uv venv --system-site-packages
48
+ uv sync
49
+ ```
50
+
51
+ `uv venv --system-site-packages` is a modern,faster alternative to `python -m venv .venv --system-site-packages`.
52
+ Because **uv** manages the build-time dependencies (**setuptools-rust** and **cffi**) in an isolated environment and coordinates the hand-off to the Rust compiler more robustly than **pip**, it is the recommended way to install **cryptography** from source on Termux.
53
+
54
+ ---
@@ -0,0 +1,27 @@
1
+ [project]
2
+ name = "dworshak-access"
3
+ version = "0.1.11"
4
+ description = "**dworshak-access** is a light-weight library for local credential access. It exposes the **get_secret()** 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.9"
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"
20
+
21
+ [dependency-groups]
22
+ dev = [
23
+ "pytest>=8.4.2",
24
+ ]
25
+
26
+ [tool.setuptools.packages.find]
27
+ where = ["src"]
@@ -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
+ from __future__ import annotations
3
+ from dworshak_access.vault import get_secret, check_vault
4
+
5
+ __all__ = [
6
+ "get_secret",
7
+ "check_vault"
8
+ ]
9
+
@@ -0,0 +1,58 @@
1
+ # src/dworshak-access/vault.py
2
+ from __future__ import annotations
3
+ import sqlite3
4
+ import os
5
+ from pathlib import Path
6
+ from typing import NamedTuple, List, Tuple, Optional
7
+ from cryptography.fernet import Fernet
8
+
9
+ DEFAULT_ROOT = Path.home() / ".dworshak"
10
+
11
+ class VaultStatus(NamedTuple):
12
+ is_valid: bool
13
+ message: str
14
+ root_path: Path
15
+
16
+ def check_vault(root: Path = DEFAULT_ROOT) -> VaultStatus:
17
+ """Diagnose the health of the Dworshak environment."""
18
+ if not root.exists():
19
+ return VaultStatus(False, "Vault directory does not exist.", root)
20
+ if not (root / ".key").exists():
21
+ return VaultStatus(False, "Security key (.key) is missing.", root)
22
+ if not (root / "vault.db").exists():
23
+ return VaultStatus(False, "Credential database (vault.db) is missing.", root)
24
+
25
+ try:
26
+ with sqlite3.connect(root / "vault.db") as conn:
27
+ conn.execute("SELECT 1 FROM credentials LIMIT 1")
28
+ except sqlite3.Error as e:
29
+ return VaultStatus(False, f"Database error: {e}", root)
30
+
31
+ return VaultStatus(True, "Vault is healthy.", root)
32
+
33
+ def get_secret(service: str, item: str, root: Path = DEFAULT_ROOT) -> str:
34
+ """Retrieve and decrypt a specific secret."""
35
+ key_path = root / ".key"
36
+ db_path = root / "vault.db"
37
+
38
+ if not key_path.exists():
39
+ raise FileNotFoundError(f"Dworshak key not found at {key_path}")
40
+
41
+ fernet = Fernet(key_path.read_bytes())
42
+
43
+ with sqlite3.connect(db_path) as conn:
44
+ try:
45
+ cursor = conn.execute(
46
+ "SELECT secret FROM credentials WHERE service = ? AND item = ?",
47
+ (service, item)
48
+ )
49
+ row = cursor.fetchone()
50
+ except sqlite3.OperationalError as e:
51
+ raise RuntimeError(f"Database schema mismatch: {e}")
52
+
53
+ if not row:
54
+ raise KeyError(f"No credential found for {service}/{item}")
55
+
56
+ return fernet.decrypt(row[0]).decode()
57
+
58
+
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.4
2
+ Name: dworshak-access
3
+ Version: 0.1.11
4
+ Summary: **dworshak-access** is a light-weight library for local credential access. It exposes the **get_secret()** 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.9
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 light-weight library for local credential access. By adding **dworshak-access** as a dependency to your Python project, you enable your program or script to leverage credentials that have been established using the Drowshak CLI tool, which is a separate package.
12
+
13
+ ## Functions exposed in **dworshak-access**:
14
+ - check_vault() # For troubleshooting automated testing.
15
+ - get_secret() # The meat and potatoes.
16
+
17
+
18
+ ### Example
19
+
20
+ ```zsh
21
+ uv add dworshak-access
22
+ ```
23
+
24
+ ```python
25
+ from dworshak_access import get_secret
26
+
27
+ service_name = "MyThirdFavoriteAPI"
28
+ item_id_u = "username"
29
+ item_id_p = "password"
30
+
31
+ un = get_secret(service_name,item_id_u)
32
+ pw = get_secret(service_name,item_id_p)
33
+
34
+ # Then use these in your program
35
+
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Cryptography Library (When Building **dworshak-access** From Source or When Using It A Dependency in Your Project)
41
+
42
+ The only external Python library used is `crytography`, for the **Fernet** class.
43
+
44
+ On a Termux system, cryptography can **(A)** be built from source or **(B)** the precompiled python-crytography dedicated Termux package can be used.
45
+
46
+ #### A. Allow cryptography to build from source (uv is better at this compared to using pip)
47
+
48
+ ```zsh
49
+ pkg install rust binutils
50
+ uv sync
51
+ ```
52
+
53
+ #### B. Use python-cryptography (This is faster but pollutes your local venv with other system site packages.)
54
+
55
+ ```zsh
56
+ pkg install python-cryptography
57
+ uv venv --system-site-packages
58
+ uv sync
59
+ ```
60
+
61
+ `uv venv --system-site-packages` is a modern,faster alternative to `python -m venv .venv --system-site-packages`.
62
+ Because **uv** manages the build-time dependencies (**setuptools-rust** and **cffi**) in an isolated environment and coordinates the hand-off to the Rust compiler more robustly than **pip**, it is the recommended way to install **cryptography** from source on Termux.
63
+
64
+ ---
@@ -0,0 +1,12 @@
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
11
+ tests/test_check_vault.py
12
+ tests/test_get_secret.py
@@ -0,0 +1 @@
1
+ cryptography>=46.0.3
@@ -0,0 +1 @@
1
+ dworshak_access
@@ -0,0 +1,18 @@
1
+ from __future__ import annotations
2
+ from pathlib import Path
3
+ from dworshak_access.vault import check_vault
4
+
5
+ def test_check_vault_reports_missing_dir(tmp_path):
6
+ """
7
+ If the folder doesn't exist, check_vault should
8
+ return a valid status object indicating it's missing.
9
+ """
10
+ # Point to a directory we know doesn't exist
11
+ fake_path = tmp_path / "non_existent_vault"
12
+
13
+ status = check_vault(root=fake_path)
14
+
15
+ # We don't want a crash/exception; we want a 'False' status
16
+ assert status.is_valid is False
17
+ assert "does not exist" in status.message
18
+ assert status.root_path == fake_path
@@ -0,0 +1,27 @@
1
+ from __future__ import annotations
2
+ import pytest
3
+ from unittest.mock import patch, MagicMock, mock_open
4
+ from dworshak_access.vault import get_secret
5
+
6
+ @patch("dworshak_access.vault.Fernet")
7
+ @patch("sqlite3.connect")
8
+ @patch("pathlib.Path.exists", return_value=True)
9
+ @patch("pathlib.Path.read_bytes", return_value=b"fake-key-bytes")
10
+ def test_get_secret_logic(mock_read, mock_exists, mock_connect, mock_fernet):
11
+ # 1. Setup the Mock Database Response
12
+ mock_conn = MagicMock()
13
+ mock_cursor = MagicMock()
14
+ # Simulate the DB returning an encrypted blob
15
+ mock_cursor.fetchone.return_value = (b"encrypted-blob",)
16
+ mock_conn.execute.return_value = mock_cursor
17
+ mock_connect.return_value.__enter__.return_value = mock_conn
18
+
19
+ # 2. Setup the Mock Decryption
20
+ mock_fernet_instance = mock_fernet.return_value
21
+ mock_fernet_instance.decrypt.return_value = b"decrypted-password"
22
+
23
+ # 3. Execution
24
+ result = get_secret("service", "item")
25
+
26
+ # 4. Assertion
27
+ assert result == "decrypted-password"