RotatyVote: in-person anonymous voting with rotating QR enrollment

Starlette backend with sqlite, rotating HMAC QR tokens pushed to a
key-protected projector page, multi-scan enrollment, optional one-time
paper codes, anonymous ballots split from participation, live question
push over websockets, e2e tests over HTTP and TLS.
This commit is contained in:
2026-08-16 12:58:26 +01:00
commit 72273d5b06
39 changed files with 3787 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import os
HOST = os.environ.get("HOST", "0.0.0.0")
PORT = int(os.environ.get("PORT", "8000"))
# url encoded in the QR codes, eg https://vote.example.org
# when empty the projector's own origin is used
PUBLIC_URL = os.environ.get("PUBLIC_URL", "").rstrip("/")
TLS_CERT = os.environ.get("TLS_CERT", "")
TLS_KEY = os.environ.get("TLS_KEY", "")
DB_PATH = os.environ.get("DB_PATH", "rotatyvote.db")
# if set, creating a poll requires this password
CREATE_PASSWORD = os.environ.get("CREATE_PASSWORD", "")
# set to 1 when a TLS-terminating reverse proxy sits in front
BEHIND_PROXY = os.environ.get("BEHIND_PROXY", "") == "1"
SECURE_COOKIES = bool(TLS_CERT) or PUBLIC_URL.startswith("https://") or BEHIND_PROXY
# extra time a code stays valid after its slot ends (network + decode latency)
TOKEN_GRACE_MS = int(os.environ.get("TOKEN_GRACE_MS", "2500"))
# slack on top of scans*interval to collect all scans of one attempt
ATTEMPT_SLACK_MS = int(os.environ.get("ATTEMPT_SLACK_MS", "8000"))
# once presence is proven, how long the voter has to type an access code
CODE_ENTRY_TTL_S = 180
MIN_INTERVAL_MS = 300
MAX_INTERVAL_MS = 5000
MIN_SCANS = 2
MAX_SCANS = 20