initial: toy notes service used to demo pragent

A deliberately small Python service — auth helpers, a sqlite-backed store, and
two request handlers — plus a .pr-review.json that steers the reviewer toward
this repo's house rules. Pull requests against it carry planted defects so the
reviewer has something real to find.
This commit is contained in:
marcos
2026-08-18 12:31:09 +00:00
commit 9378fe0427
8 changed files with 162 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
"""Token and session helpers."""
import hmac
import secrets
_SESSIONS: dict[str, str] = {}
def new_token() -> str:
"""Generate an opaque session token."""
return secrets.token_urlsafe(32)
def verify_token(supplied: str, expected: str) -> bool:
"""Constant-time token comparison."""
return hmac.compare_digest(supplied, expected)
def login(user_id: str) -> str:
token = new_token()
_SESSIONS[token] = user_id
return token
def user_for_token(token: str) -> str | None:
return _SESSIONS.get(token)