The PIN layer is a small, self-contained authentication system that fits behind any web framework. It exists to add per-request authentication inside the trusted perimeter (Tailscale), so that even when the perimeter cracks, you still have a lock.
The pieces
| Component | What it does | Where it lives |
|---|---|---|
| Middleware | Gates every request: bypass / session-check / redirect to login | Web framework's request pipeline |
| SQLite tables | Config (PIN hash, settings), sessions, blacklist, retry attempts | One file on disk |
| Login endpoint | Verifies PIN, issues a session cookie, increments retry counter on fail | POST /login |
| Logout endpoint | Deletes the session row, clears the cookie | POST /logout |
| Admin endpoints | List sessions, manage blacklist, "Revoke All" killswitch | /admin/security/* (Track 8) |
The whole schema
Four tables, no joins, no migrations needed. The next lessons walk through each component in the order requests touch them.