Compare commits
2
Commits
v1.0.2
...
30a2b9b2a6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30a2b9b2a6 | ||
|
|
eb7a2a3d18 |
+1
-1
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "envelope_authorizer"
|
||||
version = "1.0.2"
|
||||
version = "1.1.0"
|
||||
description = "CLI key-authorization manager for envelope_crypto"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
|
||||
@@ -5,16 +5,31 @@ CAN_AUTHORIZE (`?` if unreadable here). prints only fingerprint/metadata - never
|
||||
the wrapped key or DEK.
|
||||
"""
|
||||
|
||||
import logging
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from cryptography.exceptions import InvalidTag
|
||||
|
||||
from . import boot_local, doc_meta, read_flag
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _can_authorize(crypto, doc) -> str:
|
||||
"""decrypted authority of a doc as Yes/No, or `?` if unreadable here"""
|
||||
"""decrypted authority of a doc as Yes/No, or `?` if unreadable here
|
||||
|
||||
a malformed/foreign flag degrades to `?` for display continuity. a GCM auth-tag
|
||||
failure is logged first (WARNING): it is either a foreign key this host can't
|
||||
decrypt or a tampered authz record, and this layer can't tell them apart, so the
|
||||
security signal must stay visible rather than render identically to a `?`.
|
||||
"""
|
||||
try:
|
||||
return "Yes" if read_flag(crypto, doc["meta"]["authorizer"]) else "No"
|
||||
except Exception:
|
||||
except (KeyError, TypeError, ValueError):
|
||||
return "?"
|
||||
except InvalidTag:
|
||||
friendly = doc_meta(doc).get("friendly", doc.get("_id", "?"))
|
||||
log.warning("auth-tag verification failed for flag %s - foreign key or tampered record", friendly)
|
||||
return "?"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user