File size: 508 Bytes
4879fc7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | from __future__ import annotations
HANDSHAKE_FILE = ".bucket-sync-handshake"
def extract_bearer(authorization: str | None) -> str | None:
"""Pull a token out of an `Authorization: Bearer <token>` header value.
Returns None if the header is missing, malformed, or empty.
"""
if not authorization:
return None
parts = authorization.split(None, 1)
if len(parts) != 2 or parts[0].lower() != "bearer":
return None
token = parts[1].strip()
return token or None
|