Accept title-cased signature headers from HTTP clients.

This commit is contained in:
alexveley
2026-09-22 07:02:40 -04:00
parent 43d94932fb
commit 55f7e863dc
+13 -5
View File
@@ -184,6 +184,14 @@ class ReplayCache:
return True
def _hdr(headers: dict[str, str], name: str) -> str:
want = name.lower()
for key, value in headers.items():
if key.lower() == want:
return (value or "").strip()
return ""
def verify_request(
headers: dict[str, str],
http_method: str,
@@ -191,14 +199,14 @@ def verify_request(
raw_body: bytes,
replay: ReplayCache,
) -> dict[str, Any]:
auth = headers.get("Authorization") or headers.get("authorization") or ""
match = re.fullmatch(r"FAB-ED25519 id=([0-9a-f]{32})", auth.strip())
auth = _hdr(headers, "Authorization")
match = re.fullmatch(r"FAB-ED25519 id=([0-9a-f]{32})", auth)
if not match:
raise PermissionError("signed FAB-ED25519 client required")
client_id = match.group(1)
timestamp = (headers.get("X-FAB-Timestamp") or headers.get("x-fab-timestamp") or "").strip()
nonce = (headers.get("X-FAB-Nonce") or headers.get("x-fab-nonce") or "").strip()
signature = (headers.get("X-FAB-Signature") or headers.get("x-fab-signature") or "").strip()
timestamp = _hdr(headers, "X-FAB-Timestamp")
nonce = _hdr(headers, "X-FAB-Nonce")
signature = _hdr(headers, "X-FAB-Signature")
if not timestamp.isdigit() or not nonce or not signature:
raise PermissionError("missing signature headers")
now = time.time()