pydantic_encryption 0.9.2__tar.gz → 0.9.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.
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/PKG-INFO +6 -6
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/README.md +5 -5
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/integrations/sqlalchemy/descriptor.py +4 -6
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pyproject.toml +1 -1
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/LICENSE +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/__init__.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/adapters/__init__.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/adapters/base.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/adapters/blind_index/__init__.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/adapters/blind_index/argon2.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/adapters/blind_index/hmac_sha256.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/adapters/encryption/__init__.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/adapters/encryption/aws.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/adapters/encryption/fernet.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/adapters/hashing/__init__.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/adapters/hashing/argon2.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/adapters/registry.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/config.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/integrations/__init__.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/integrations/sqlalchemy/__init__.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/integrations/sqlalchemy/async_bridge.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/integrations/sqlalchemy/blind_index.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/integrations/sqlalchemy/bulk.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/integrations/sqlalchemy/deferred.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/integrations/sqlalchemy/encryption.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/integrations/sqlalchemy/hashing.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/integrations/sqlalchemy/serialization.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/integrations/sqlalchemy/state.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/lazy.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/models/__init__.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/models/base.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/normalization.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/types.py +0 -0
- {pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/scripts/run_tests.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydantic_encryption
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.4
|
|
4
4
|
Summary: Encryption, hashing, and blind indexing for Pydantic
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Author: Julien Kmec
|
|
@@ -51,7 +51,7 @@ Field-level encryption, hashing, and blind indexing for Pydantic models with SQL
|
|
|
51
51
|
pip install pydantic-encryption
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
### Optional
|
|
54
|
+
### Optional Extras
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
57
|
pip install "pydantic-encryption[sqlalchemy]" # SQLAlchemy integration
|
|
@@ -220,11 +220,11 @@ async with AsyncSession(engine) as session:
|
|
|
220
220
|
await decrypt_values(ciphertexts, concurrency=8) # flat ciphertexts; preserves None positions
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
-
### Safety:
|
|
223
|
+
### Safety: Catching Accidental Ciphertext Access
|
|
224
224
|
|
|
225
|
-
Reads go through the on-access descriptor.
|
|
225
|
+
Reads go through the on-access descriptor. When the underlying cell is still an `EncryptedValue`, the descriptor prefers an async batch decrypt over the session's pending siblings (via SQLAlchemy's greenlet bridge), and transparently falls back to a synchronous decrypt either when the read happens outside a greenlet or when the instance is detached from any session.
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
An `EncryptedValue` only reaches user code if something bypasses the descriptor entirely (raw `state.dict[col]`, a logged row). Coercing it via `str(value)` / `f"{value}"` / `"%s" % value` raises `EncryptedValueAccessError`. `repr(value)` is a safe `<EncryptedValue: N bytes>` marker, and `bytes(value)` returns the raw ciphertext. Use `is_encrypted(value)` to guard at a boundary.
|
|
228
228
|
|
|
229
229
|
## Manual Encryption or Hashing
|
|
230
230
|
|
|
@@ -308,7 +308,7 @@ AWS_KMS_DECRYPT_KEY_ARN=arn:aws:kms:...decrypt-key
|
|
|
308
308
|
|
|
309
309
|
Use one mode or the other — combining `AWS_KMS_KEY_ARN` with either split variant raises a validation error. A decrypt-only key alone is allowed (read-only workloads).
|
|
310
310
|
|
|
311
|
-
#### Plaintext
|
|
311
|
+
#### Plaintext Cache (Opt-In)
|
|
312
312
|
|
|
313
313
|
For read-heavy workloads that repeatedly decrypt the same ciphertexts, AWS KMS round-trips dominate. An in-process LRU of ciphertext → plaintext is available as opt-in:
|
|
314
314
|
|
|
@@ -8,7 +8,7 @@ Field-level encryption, hashing, and blind indexing for Pydantic models with SQL
|
|
|
8
8
|
pip install pydantic-encryption
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
### Optional
|
|
11
|
+
### Optional Extras
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
pip install "pydantic-encryption[sqlalchemy]" # SQLAlchemy integration
|
|
@@ -177,11 +177,11 @@ async with AsyncSession(engine) as session:
|
|
|
177
177
|
await decrypt_values(ciphertexts, concurrency=8) # flat ciphertexts; preserves None positions
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
-
### Safety:
|
|
180
|
+
### Safety: Catching Accidental Ciphertext Access
|
|
181
181
|
|
|
182
|
-
Reads go through the on-access descriptor.
|
|
182
|
+
Reads go through the on-access descriptor. When the underlying cell is still an `EncryptedValue`, the descriptor prefers an async batch decrypt over the session's pending siblings (via SQLAlchemy's greenlet bridge), and transparently falls back to a synchronous decrypt either when the read happens outside a greenlet or when the instance is detached from any session.
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
An `EncryptedValue` only reaches user code if something bypasses the descriptor entirely (raw `state.dict[col]`, a logged row). Coercing it via `str(value)` / `f"{value}"` / `"%s" % value` raises `EncryptedValueAccessError`. `repr(value)` is a safe `<EncryptedValue: N bytes>` marker, and `bytes(value)` returns the raw ciphertext. Use `is_encrypted(value)` to guard at a boundary.
|
|
185
185
|
|
|
186
186
|
## Manual Encryption or Hashing
|
|
187
187
|
|
|
@@ -265,7 +265,7 @@ AWS_KMS_DECRYPT_KEY_ARN=arn:aws:kms:...decrypt-key
|
|
|
265
265
|
|
|
266
266
|
Use one mode or the other — combining `AWS_KMS_KEY_ARN` with either split variant raises a validation error. A decrypt-only key alone is allowed (read-only workloads).
|
|
267
267
|
|
|
268
|
-
#### Plaintext
|
|
268
|
+
#### Plaintext Cache (Opt-In)
|
|
269
269
|
|
|
270
270
|
For read-heavy workloads that repeatedly decrypt the same ciphertexts, AWS KMS round-trips dominate. An in-process LRU of ciphertext → plaintext is available as opt-in:
|
|
271
271
|
|
|
@@ -14,7 +14,7 @@ from sqlalchemy.orm import object_session
|
|
|
14
14
|
|
|
15
15
|
from pydantic_encryption.integrations.sqlalchemy.state import pending_siblings
|
|
16
16
|
from pydantic_encryption.integrations.sqlalchemy.bulk import decrypt_rows, decrypt_rows_sync
|
|
17
|
-
from pydantic_encryption.types import EncryptedValue
|
|
17
|
+
from pydantic_encryption.types import EncryptedValue
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class DecryptOnAccessDescriptor:
|
|
@@ -43,12 +43,10 @@ class DecryptOnAccessDescriptor:
|
|
|
43
43
|
|
|
44
44
|
session = object_session(instance)
|
|
45
45
|
if session is None:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
)
|
|
46
|
+
rows: list[Any] | set[Any] = [instance]
|
|
47
|
+
else:
|
|
48
|
+
rows = {instance, *pending_siblings(session, self._cls)}
|
|
50
49
|
|
|
51
|
-
rows = {instance, *pending_siblings(session, self._cls)}
|
|
52
50
|
try:
|
|
53
51
|
await_(decrypt_rows(rows, self._column_key))
|
|
54
52
|
except MissingGreenlet:
|
|
File without changes
|
|
File without changes
|
{pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/adapters/__init__.py
RENAMED
|
File without changes
|
{pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/adapters/base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/adapters/registry.py
RENAMED
|
File without changes
|
|
File without changes
|
{pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/integrations/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/models/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{pydantic_encryption-0.9.2 → pydantic_encryption-0.9.4}/pydantic_encryption/normalization.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|