Implement code word based remote authentication (#1)

Add comprehensive remote authentication system allowing users to log in from one device by authenticating from another trusted device. Features include:

- Proof of Work (PoW) protection using PBKDF2-SHA512 to prevent abuse
- Simple pairing codes (3 words) protected by dynamic PoW difficulty
- Autocomplete pairing code input with error checking
- Real-time WebSocket communication between devices

Unlike device addition links and reset links with QR codes that only allow adding an authentication method, and that work offline over the duration of several days, this mechanism is strictly online, with 5 minute time limit.
This commit is contained in:
2025-12-08 23:56:48 +00:00
parent 83419d1845
commit 1bed2c39d8
57 changed files with 3668 additions and 503 deletions
+3 -3
View File
@@ -19,7 +19,7 @@ def is_root_mode() -> bool:
return _load_config().get("auth_host") is not None
def configured_auth_host() -> str | None:
def dedicated_auth_host() -> str | None:
"""Return configured auth_host netloc, or None."""
auth_host = _load_config().get("auth_host")
if not auth_host:
@@ -34,7 +34,7 @@ def ui_base_path() -> str:
return "/" if is_root_mode() else "/auth/"
def auth_site_base_url() -> str:
def auth_site_url() -> str:
"""Return the base URL for the auth site UI (computed at startup)."""
cfg = _load_config()
return cfg.get("site_url", "https://localhost") + cfg.get("site_path", "/auth/")
@@ -42,7 +42,7 @@ def auth_site_base_url() -> str:
def reset_link_url(token: str) -> str:
"""Generate a reset link URL for the given token."""
return f"{auth_site_base_url()}{token}"
return f"{auth_site_url()}{token}"
def normalize_origin(origin: str) -> str: