You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document codifies security-critical boundaries as enforceable design rules. Security assumptions become explicit contracts — violations are treated as bugs, not style issues.
1. Session Transport Contract
Session Cookie
Rule
Policy
Transport
cb_session httpOnly cookie only
Cookie scope
Sent automatically with credentials: 'include'
Query params
❌ NEVER — session identifiers must not appear in URLs
Request body
❌ NEVER — auth session tokens are transport metadata
localStorage/sessionStorage
❌ NEVER — browser-accessible storage must not hold auth sessions
Server-side storage
Session records in SQLite (sessions table); token hash only
Implementation
Backend: Session middleware and auth routes read/write cb_session cookie
Frontend: All authenticated API calls include credentials: 'include'
OAuth state: cb_oauth cookie stores Fernet-encrypted state payload for callback validation
Application refuses to start if the session secret is too weak for the environment. This is a hard fail, not a warning.
raiseValueError(
f"JWT secret is too weak for env '{self.app_env}'. ""Set CLOUDBLOCKS_JWT_SECRET to a random string of at least 32 characters."
)
3. OAuth State Lifecycle Contract
GitHub App OAuth Flow
1. User clicks "Sign in with GitHub" in frontend
2. Frontend redirects to GitHub authorization URL
3. GitHub redirects back with ?code=... and ?state=...
4. Backend exchanges code for access token
5. Backend creates/links user identity
6. Backend creates server-side session + sets httpOnly `cb_session` cookie
7. Frontend uses cookie automatically on API calls (`credentials: 'include'`)