# Security Guide This project is a stateless OAuth2 resource server with ACL-controlled writes. ## Authentication - Validate JWT signature against `OAUTH_JWKS_URL`. - Validate token expiration and audience (`OAUTH_AUDIENCE`). - Keep token validation centralized and identity-provider agnostic. - Attach authenticated principal to request context after validation. - Do not introduce session-based auth or server-side session state. ## Browser Token Storage — Two-Store Design The frontend stores the JWT in two places simultaneously, each serving a distinct audience: | Store | Who reads it | Purpose | |---|---|---| | `localStorage` (`docroot_token`) | JavaScript | `fetch()` calls construct `Authorization: Bearer ` headers. `isAuthenticated()`, the token dialog, and upload forms all read from the reactive `token` ref. | | `session` cookie (`HttpOnly; SameSite=Lax`) | The browser | Attached automatically to every same-origin request, including `