mirror of
https://github.com/corazoncp/zoom-sched-poc.git
synced 2026-12-01 04:50:31 +00:00
docs: reconcile README, add ARCHITECTURE.md, and record ADR-0001
- README.md: document gated zoom_start_url, payment_processing guard, 64 KiB cap, single-worker Docker note, and doc links - ARCHITECTURE.md: document component responsibilities, SQLite appointment state machine, and trust boundaries - docs/adr/0001-transient-credentials-and-gated-host-url.md: record decision for browser-memory-only credentials and gated host URL
This commit is contained in:
1 parent
22bbc0c0a8
commit
091b9a031a
3 files changed
+69
-5
No files matched your search
@@ -0,0 +1,42 @@
|
||||
# Architecture — `zoom-sched-poc`
|
||||
|
||||
Canonical present-state architecture for the **zoom-sched-poc** proof-of-concept (`feat/zoom-sched-poc`).
|
||||
|
||||
## System Topology
|
||||
|
||||
Single-container Flask + Gunicorn (`--workers 1 --threads 4`) application serving both the static 3-screen presentation UI and the JSON REST API behind a reverse proxy (Traefik).
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
Browser["Browser (3-Screen SPA)<br/>Credentials in tab memory"] -->|HTTPS| Proxy["Reverse Proxy (Traefik)"]
|
||||
Proxy -->|X-Forwarded-*| Flask["Flask App (ProxyFix + Limiter)<br/>MAX_CONTENT_LENGTH: 64 KiB"]
|
||||
Flask --> DB[("SQLite WAL<br/>/app/data/appointments.db")]
|
||||
Flask -->|HTTPS Bearer / Basic| Zoom["Zoom REST & OAuth API"]
|
||||
```
|
||||
|
||||
## Module Responsibilities
|
||||
|
||||
| Module | Responsibility |
|
||||
| :--- | :--- |
|
||||
| [`app/__init__.py`](app/__init__.py) | App factory (`create_app`), `ProxyFix`, `Flask-Limiter` (`memory://`), `_resolve_appointment`, HTTP routes, and error handlers (`413`, `429`, `ZoomAPIError`). |
|
||||
| [`app/schemas.py`](app/schemas.py) | Pydantic v2 request/response models; `ZoomCredentials.client_secret` uses `SecretStr`. |
|
||||
| [`app/db.py`](app/db.py) | SQLite WAL initialization (`init_db`) and atomic state transitions (`create_appointment`, `claim_appointment_for_payment`, `release_payment_claim`, `mark_appointment_confirmed`, `delete_appointment`). |
|
||||
| [`app/zoom.py`](app/zoom.py) | Zoom Server-to-Server OAuth token exchange, paginated slot conflict detection (`max_pages=20`), meeting creation, and meeting deletion. |
|
||||
| [`app/templates/index.html`](app/templates/index.html) & [`static/style.css`](static/style.css) | 3-screen smooth-scroll presentation UI with `escapeHtml()` and `safeHttpUrl()` (`http:`/`https:` only). |
|
||||
|
||||
## Appointment State Machine
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
[*] --> payment_pending: "POST /api/appointments (slot free)"
|
||||
payment_pending --> payment_processing: "POST /pay atomic claim"
|
||||
payment_processing --> payment_pending: "Zoom create_meeting fails (release)"
|
||||
payment_processing --> confirmed: "Zoom meeting created"
|
||||
payment_pending --> [*]: "DELETE (no Zoom call)"
|
||||
confirmed --> [*]: "DELETE (deletes Zoom meeting)"
|
||||
```
|
||||
|
||||
## Trust Boundaries & Rate Limits
|
||||
- **Zoom credentials (`account_id`, `client_id`, `client_secret`)** are never written to SQLite, cookies, or disk; they are validated per request on `/api/zoom/verify-credentials`, `/api/appointments`, `/pay`, and `DELETE`.
|
||||
- **Host ZAK link (`zoom_start_url`)** is omitted on unauthenticated `GET /api/appointments/<lookup_id>` and returned only by `POST /pay` after credential verification.
|
||||
- **Brute-force rate limits** (`Flask-Limiter` `memory://` in a single Gunicorn worker): `60/min` default, `10/min` on `/verify-credentials`, `/pay`, and `DELETE`, `15/min` on `POST /api/appointments`, `20/min` on `GET /api/appointments/<lookup_id>`.
|
||||
@@ -4,10 +4,13 @@ Interactive 3-screen presentation proof-of-concept for **El Corazón como Portal
|
||||
|
||||
## Features
|
||||
- **3-screen presentation flow** with automatic smooth scrolling:
|
||||
1. **Configuración (Servidor):** Validates Zoom Server-to-Server OAuth credentials in memory (`SecretStr` in Pydantic; never persisted to SQLite or disk).
|
||||
2. **Solicitar una Cita (Como cliente):** Checks Zoom upcoming meetings for conflicts (`GET /v2/users/me/meetings`), then creates a `payment_pending` appointment in SQLite and returns `session_id` + `payment_id`.
|
||||
3. **Buscar Sesión:** Looks up `session_id` or `payment_id`, simulates payment confirmation, provisions the Zoom meeting (`POST /v2/users/me/meetings`), and displays session links idempotently on repeat lookups.
|
||||
- **Brute-force protection:** `Flask-Limiter` per-IP rate limits (with `ProxyFix` for Traefik) and 40-bit random `ses_`/`pay_` IDs.
|
||||
1. **Configuración (Servidor):** Validates Zoom Server-to-Server OAuth credentials (`POST /api/zoom/verify-credentials`) using `SecretStr` in Pydantic; credentials stay strictly in browser tab memory and are never persisted to SQLite or disk.
|
||||
2. **Solicitar una Cita (Como cliente):** Checks Zoom upcoming meetings for time overlaps (`GET /v2/users/me/meetings`, paginated up to 20 pages), persists a `payment_pending` appointment (including `duration_minutes`) in SQLite, and returns `session_id` + `payment_id`.
|
||||
3. **Buscar Sesión:** Looks up `session_id` or `payment_id` (`GET /api/appointments/<lookup_id>`), lets the presenter confirm mock payment (`POST /api/appointments/<lookup_id>/pay`) to provision the Zoom meeting (`POST /v2/users/me/meetings`), and handles repeat lookups idempotently.
|
||||
- **Security & concurrency invariants:**
|
||||
- Unauthenticated `GET /api/appointments/<lookup_id>` omits `zoom_start_url` (host ZAK token); `zoom_start_url` is returned only by `POST /pay` after verifying Zoom credentials.
|
||||
- Atomic `payment_processing` claim/release prevents duplicate Zoom meetings on concurrent `/pay` requests, and `DELETE` returns `409 Conflict` while a payment is in flight.
|
||||
- `ProxyFix` + `Flask-Limiter` (`memory://`, single Gunicorn worker `--workers 1 --threads 4`), `MAX_CONTENT_LENGTH` (64 KiB), `safeHttpUrl()` link scheme validation, and 40-bit random `ses_`/`pay_` IDs.
|
||||
|
||||
## Local Development
|
||||
|
||||
@@ -19,12 +22,18 @@ uv run flask --app "app:create_app()" run --debug --port 8000
|
||||
Run tests:
|
||||
|
||||
```bash
|
||||
uv run pytest
|
||||
uv run pytest -v
|
||||
```
|
||||
|
||||
## Single-Container Docker Run
|
||||
|
||||
The container runs as non-root `appuser` with `--workers 1 --threads 4` (required for authoritative in-memory rate limiting) and a built-in `HEALTHCHECK` on `/health`.
|
||||
|
||||
```bash
|
||||
docker build -t zoom-sched-poc .
|
||||
docker run -p 8000:8000 -v zoom_sched_data:/app/data zoom-sched-poc
|
||||
```
|
||||
|
||||
## Documentation
|
||||
- [Architecture Overview](./ARCHITECTURE.md)
|
||||
- [ADR-0001: Transient Credentials and Gated Host URL](./docs/adr/0001-transient-credentials-and-gated-host-url.md)
|
||||
@@ -0,0 +1,13 @@
|
||||
# ADR-0001: Transient Zoom Credentials and Gated Host URL
|
||||
|
||||
- **Status:** Accepted
|
||||
- **Date:** 2026-11-21
|
||||
- **Context:** `zoom-sched-poc` is a public-facing proof-of-concept demo allowing Azu to test end-to-end Zoom scheduling with her own Server-to-Server OAuth app without deploying an authentication gateway (Authelia) or persisting third-party secrets on the homelab server.
|
||||
|
||||
## Decision
|
||||
1. **Transient browser-memory credentials:** Zoom `account_id`, `client_id`, and `client_secret` are entered in Screen 1, held solely in browser tab memory, and transmitted per request over HTTPS (`SecretStr` in Pydantic). They are never stored in SQLite, session cookies, or server environment files.
|
||||
2. **Gated `zoom_start_url`:** Unauthenticated `GET /api/appointments/<lookup_id>` omits `zoom_start_url` (which embeds a Zoom host ZAK token) and returns only client-safe metadata (`zoom_join_url`, `zoom_meeting_id`). `zoom_start_url` is returned only from `POST /api/appointments/<lookup_id>/pay` after verifying the caller's Zoom credentials via `zoom.get_access_token`.
|
||||
|
||||
## Consequences
|
||||
- **Positive:** Eliminates server-side secret storage and prevents anyone holding a `session_id`/`payment_id` from hijacking host controls via unauthenticated `GET` lookup.
|
||||
- **Negative / Trade-off:** Refreshing the browser tab requires re-entering Zoom credentials in Screen 1, and Screen 3 `BUSCAR` lookup alone does not display the host link unless payment is confirmed in the same flow.
|
||||
Reference in new issue
Block a user