vault-handoff 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.
@@ -0,0 +1,10 @@
1
+ node_modules/
2
+ dist/
3
+ *.tsbuildinfo
4
+ __pycache__/
5
+ *.egg-info/
6
+ .venv/
7
+ .pytest_cache/
8
+ .ruff_cache/
9
+ build/
10
+ coverage/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ramot systems inc.
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,131 @@
1
+ Metadata-Version: 2.5
2
+ Name: vault-handoff
3
+ Version: 0.1.0
4
+ Summary: Password-unlocked server vault with forward-secret, end-to-end encrypted password hand-off between logged-in browsers (Flask/WSGI)
5
+ Project-URL: Homepage, https://github.com/Ramot-systems-inc/vault-handoff
6
+ Project-URL: Specification, https://github.com/Ramot-systems-inc/vault-handoff/blob/master/SPEC.md
7
+ Author: Ramot Systems Inc.
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: ecies,end-to-end-encryption,flask,forward-secrecy,sqlcipher,vault
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Framework :: Flask
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Security :: Cryptography
16
+ Requires-Python: >=3.10
17
+ Requires-Dist: cryptography>=42
18
+ Provides-Extra: flask
19
+ Requires-Dist: flask>=3.0; extra == 'flask'
20
+ Provides-Extra: lint
21
+ Requires-Dist: ruff==0.16.9; extra == 'lint'
22
+ Provides-Extra: test
23
+ Requires-Dist: flask>=3.0; extra == 'test'
24
+ Requires-Dist: pytest>=8; extra == 'test'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # vault-handoff (Python)
28
+
29
+ Server side of [vault-handoff](https://github.com/Ramot-systems-inc/vault-handoff)
30
+ for Flask and other WSGI apps. Your data lives in a store encrypted under a key
31
+ derived from one shared DB password. The password is never written anywhere:
32
+ the server starts **locked** after every restart, and a logged-in user unlocks
33
+ it by typing the password, or gets it end-to-end encrypted from a colleague's
34
+ browser that already holds it.
35
+
36
+ Every message that carries the password is sealed to an ephemeral key that only
37
+ ever exists in RAM, so a recording of today's traffic stays useless even to
38
+ someone who later boots a disk snapshot of the server with its TLS keys. See
39
+ [SPEC.md](https://github.com/Ramot-systems-inc/vault-handoff/blob/master/SPEC.md)
40
+ for the protocol and the threat model.
41
+
42
+ ## Install
43
+
44
+ ```bash
45
+ pip install "vault-handoff[flask]"
46
+ ```
47
+
48
+ ## Use
49
+
50
+ ```python
51
+ from vault_handoff import Principal, Vault, WrongKeyError
52
+ from vault_handoff.flask import create_blueprint
53
+
54
+
55
+ class SqlCipherStore:
56
+ """Your encrypted store. Copy the keys you keep: the vault zeroes its buffers."""
57
+
58
+ def __init__(self, path):
59
+ self.path = path
60
+
61
+ def exists(self):
62
+ return self.path.exists()
63
+
64
+ def open(self, keys, *, create):
65
+ conn = sqlcipher3.connect(self.path)
66
+ conn.execute(f"PRAGMA key = \"x'{bytes(keys['db']).hex()}'\"")
67
+ try:
68
+ conn.execute("SELECT count(*) FROM sqlite_master")
69
+ except sqlcipher3.DatabaseError:
70
+ conn.close()
71
+ raise WrongKeyError() from None
72
+ return conn
73
+
74
+ def rekey(self, conn, next_keys):
75
+ conn.execute(f"PRAGMA rekey = \"x'{bytes(next_keys['db']).hex()}'\"")
76
+
77
+ def close(self, conn):
78
+ conn.close()
79
+
80
+
81
+ vault = Vault(
82
+ app_id="myapp",
83
+ data_dir="data",
84
+ storage=SqlCipherStore(Path("data/app.db")),
85
+ subkeys={"db": "myapp-db"},
86
+ allow_create=True, # the first login chooses the password
87
+ )
88
+
89
+
90
+ def current_principal():
91
+ if not current_user.is_authenticated:
92
+ return None
93
+ return Principal(
94
+ sid=session["sid"],
95
+ user_id=current_user.id,
96
+ name=current_user.name,
97
+ can_share=current_user.is_staff,
98
+ username=current_user.username, # what the hand-off policy matches
99
+ hive_token=session.get("hive_token"), # only with Hive key attestation
100
+ )
101
+
102
+
103
+ app.register_blueprint(create_blueprint(vault, current_principal))
104
+ ```
105
+
106
+ Routes go under `/api/vault`, and the browser client under
107
+ `/api/vault/static/vault-handoff.browser.mjs` (the same code as the npm
108
+ package's `@ramot-systems-inc/vault-handoff/browser`).
109
+
110
+ In request handlers, `vault.require_handle()` returns the open store, or raises
111
+ `VaultError("locked")`. `vault.is_verified(sid)` tells whether this login has
112
+ entered (or received) the password since the last unlock.
113
+
114
+ The hand-off policy and security alerts are configured from the environment,
115
+ the same way for every app (see the repository README): `Vault(...,
116
+ handoff_policy=..., alerts=...)` overrides them, and `alerts=False` turns
117
+ alerts off. Alerts go out on a background thread. Behind a proxy that doesn't
118
+ set `X-Real-IP` or `X-Forwarded-For`, pass `create_blueprint(..., get_ip=...)`.
119
+
120
+ ## Run one process
121
+
122
+ The vault keeps its keys and sessions in memory, so run a single process
123
+ (threads are fine): `gunicorn -w 1 --threads 8 app:app`. A second process on the
124
+ same data directory refuses to start.
125
+
126
+ ## Hosts
127
+
128
+ Turn swap off (or encrypt it), and disable hibernation: memory of an unlocked
129
+ server holds the keys. The vault locks and zeroes its keys on `SIGTERM` and
130
+ `SIGINT`, and `POST /api/vault/lock` locks it on demand (for example before a
131
+ snapshot).
@@ -0,0 +1,105 @@
1
+ # vault-handoff (Python)
2
+
3
+ Server side of [vault-handoff](https://github.com/Ramot-systems-inc/vault-handoff)
4
+ for Flask and other WSGI apps. Your data lives in a store encrypted under a key
5
+ derived from one shared DB password. The password is never written anywhere:
6
+ the server starts **locked** after every restart, and a logged-in user unlocks
7
+ it by typing the password, or gets it end-to-end encrypted from a colleague's
8
+ browser that already holds it.
9
+
10
+ Every message that carries the password is sealed to an ephemeral key that only
11
+ ever exists in RAM, so a recording of today's traffic stays useless even to
12
+ someone who later boots a disk snapshot of the server with its TLS keys. See
13
+ [SPEC.md](https://github.com/Ramot-systems-inc/vault-handoff/blob/master/SPEC.md)
14
+ for the protocol and the threat model.
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ pip install "vault-handoff[flask]"
20
+ ```
21
+
22
+ ## Use
23
+
24
+ ```python
25
+ from vault_handoff import Principal, Vault, WrongKeyError
26
+ from vault_handoff.flask import create_blueprint
27
+
28
+
29
+ class SqlCipherStore:
30
+ """Your encrypted store. Copy the keys you keep: the vault zeroes its buffers."""
31
+
32
+ def __init__(self, path):
33
+ self.path = path
34
+
35
+ def exists(self):
36
+ return self.path.exists()
37
+
38
+ def open(self, keys, *, create):
39
+ conn = sqlcipher3.connect(self.path)
40
+ conn.execute(f"PRAGMA key = \"x'{bytes(keys['db']).hex()}'\"")
41
+ try:
42
+ conn.execute("SELECT count(*) FROM sqlite_master")
43
+ except sqlcipher3.DatabaseError:
44
+ conn.close()
45
+ raise WrongKeyError() from None
46
+ return conn
47
+
48
+ def rekey(self, conn, next_keys):
49
+ conn.execute(f"PRAGMA rekey = \"x'{bytes(next_keys['db']).hex()}'\"")
50
+
51
+ def close(self, conn):
52
+ conn.close()
53
+
54
+
55
+ vault = Vault(
56
+ app_id="myapp",
57
+ data_dir="data",
58
+ storage=SqlCipherStore(Path("data/app.db")),
59
+ subkeys={"db": "myapp-db"},
60
+ allow_create=True, # the first login chooses the password
61
+ )
62
+
63
+
64
+ def current_principal():
65
+ if not current_user.is_authenticated:
66
+ return None
67
+ return Principal(
68
+ sid=session["sid"],
69
+ user_id=current_user.id,
70
+ name=current_user.name,
71
+ can_share=current_user.is_staff,
72
+ username=current_user.username, # what the hand-off policy matches
73
+ hive_token=session.get("hive_token"), # only with Hive key attestation
74
+ )
75
+
76
+
77
+ app.register_blueprint(create_blueprint(vault, current_principal))
78
+ ```
79
+
80
+ Routes go under `/api/vault`, and the browser client under
81
+ `/api/vault/static/vault-handoff.browser.mjs` (the same code as the npm
82
+ package's `@ramot-systems-inc/vault-handoff/browser`).
83
+
84
+ In request handlers, `vault.require_handle()` returns the open store, or raises
85
+ `VaultError("locked")`. `vault.is_verified(sid)` tells whether this login has
86
+ entered (or received) the password since the last unlock.
87
+
88
+ The hand-off policy and security alerts are configured from the environment,
89
+ the same way for every app (see the repository README): `Vault(...,
90
+ handoff_policy=..., alerts=...)` overrides them, and `alerts=False` turns
91
+ alerts off. Alerts go out on a background thread. Behind a proxy that doesn't
92
+ set `X-Real-IP` or `X-Forwarded-For`, pass `create_blueprint(..., get_ip=...)`.
93
+
94
+ ## Run one process
95
+
96
+ The vault keeps its keys and sessions in memory, so run a single process
97
+ (threads are fine): `gunicorn -w 1 --threads 8 app:app`. A second process on the
98
+ same data directory refuses to start.
99
+
100
+ ## Hosts
101
+
102
+ Turn swap off (or encrypt it), and disable hibernation: memory of an unlocked
103
+ server holds the keys. The vault locks and zeroes its keys on `SIGTERM` and
104
+ `SIGINT`, and `POST /api/vault/lock` locks it on demand (for example before a
105
+ snapshot).
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "vault-handoff"
7
+ version = "0.1.0"
8
+ description = "Password-unlocked server vault with forward-secret, end-to-end encrypted password hand-off between logged-in browsers (Flask/WSGI)"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ authors = [{ name = "Ramot Systems Inc." }]
14
+ keywords = ["vault", "sqlcipher", "ecies", "end-to-end-encryption", "forward-secrecy", "flask"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Framework :: Flask",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Topic :: Security :: Cryptography",
21
+ ]
22
+ dependencies = ["cryptography>=42"]
23
+
24
+ [project.optional-dependencies]
25
+ flask = ["flask>=3.0"]
26
+ test = ["pytest>=8", "flask>=3.0"]
27
+ # The org-wide ruff pin (see ruff.toml): CI and local lint use exactly this.
28
+ lint = ["ruff==0.16.9"]
29
+
30
+ [project.urls]
31
+ Homepage = "https://github.com/Ramot-systems-inc/vault-handoff"
32
+ Specification = "https://github.com/Ramot-systems-inc/vault-handoff/blob/master/SPEC.md"
33
+
34
+ [tool.hatch.build.targets.wheel]
35
+ packages = ["src/vault_handoff"]
36
+
37
+ [tool.hatch.build.targets.sdist]
38
+ include = ["src/vault_handoff", "tests", "README.md", "LICENSE"]
39
+
40
+ [tool.pytest.ini_options]
41
+ testpaths = ["tests"]
@@ -0,0 +1,63 @@
1
+ """vault-handoff: a password-unlocked server vault with forward-secret,
2
+ end-to-end encrypted password hand-off between logged-in browsers.
3
+
4
+ See SPEC.md in the repository for the protocol and the threat model.
5
+ """
6
+
7
+ from .alerts import (
8
+ SECURITY_EVENT_TEXT,
9
+ AlertSink,
10
+ SecurityEvent,
11
+ alerts_from_env,
12
+ format_security_alert,
13
+ markdown_code_span,
14
+ mattermost_bot_alerts,
15
+ mattermost_webhook_alerts,
16
+ peekaboo_alerts,
17
+ )
18
+ from .attestation import (
19
+ AttestationError,
20
+ HiveAttestation,
21
+ verify_key_attestation,
22
+ )
23
+ from .http import NO_STORE_HEADERS, handle_request
24
+ from .kdf import DEFAULT_KDF, KdfParams, check_verifier, derive_keys, make_verifier
25
+ from .policy import DEFAULT_POLICY, HandoffPolicy, approval_for, parse_handoff_policy
26
+ from .protocol import Principal, VaultError
27
+ from .seal import handoff_code
28
+ from .vault import AuditEvent, StorageAdapter, Vault, WrongKeyError
29
+
30
+ __all__ = [
31
+ "DEFAULT_KDF",
32
+ "DEFAULT_POLICY",
33
+ "NO_STORE_HEADERS",
34
+ "SECURITY_EVENT_TEXT",
35
+ "AlertSink",
36
+ "AttestationError",
37
+ "AuditEvent",
38
+ "HandoffPolicy",
39
+ "HiveAttestation",
40
+ "KdfParams",
41
+ "Principal",
42
+ "SecurityEvent",
43
+ "StorageAdapter",
44
+ "Vault",
45
+ "VaultError",
46
+ "WrongKeyError",
47
+ "alerts_from_env",
48
+ "approval_for",
49
+ "check_verifier",
50
+ "derive_keys",
51
+ "format_security_alert",
52
+ "handle_request",
53
+ "handoff_code",
54
+ "make_verifier",
55
+ "markdown_code_span",
56
+ "mattermost_bot_alerts",
57
+ "mattermost_webhook_alerts",
58
+ "parse_handoff_policy",
59
+ "peekaboo_alerts",
60
+ "verify_key_attestation",
61
+ ]
62
+
63
+ __version__ = "0.1.0"