Repository navigation
[M2.2e4a] Serve browser assets with strict CSP and same-origin identity - #72
Merged
Merged
Conversation
6 tasks done
samuelmbabhazi
force-pushed
the
feat/m2.2e3d-token-screens
branch
from
November 5, 2026 12:41
ee2d72f to
f60fd32
Compare
samuelmbabhazi
changed the base branch from
feat/m2.2e3d-token-screens
to
main
November 5, 2026 12:41
samuelmbabhazi
force-pushed
the
feat/m2.2e4a-serve-web
branch
from
November 5, 2026 12:41
ded9ee7 to
cab4ea8
Compare
samuelmbabhazi
marked this pull request as ready for review
November 5, 2026 12:41
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
## Task [M2.2e4b1] Real-browser identity acceptance. Stacked on #72; review the prerequisite stack before merging. No merge requested. ## What changed and why The production Angular build normalizes `ngCspNonce` to lowercase and copies its placeholder onto generated script/style tags. The server previously rejected that real build at startup. Accept the normalized attribute and replace every placeholder with the same fresh per-response nonce; retain strict CSP and add a focused HTTP regression test. Add `pnpm test:browser` and a CI job running pinned Chromium against production assets and a real Nest API, disposable PostgreSQL, and local TLS SMTP. The suite covers all six public forms, signup → delivered verification code → login → logout, secure session/CSRF cookies, missing-CSRF and foreign-Origin rejection, empty browser storage, secret-free navigation URLs, strict CSP execution, error focus, automated WCAG rules, and horizontal overflow at 320/390/768/1024/1440 pixels. Account security receives an automated accessibility check after login. ## How it was tested - Chromium: both acceptance scenarios pass against real HTTPS, PostgreSQL and SMTP. - Workspace lint, typecheck and TypeScript tests: all seven projects pass, including 103 API unit tests and 50 Angular tests. - API integration: 84 tests across 19 files pass with disposable databases and Nx dotenv loading disabled. - Production API/web builds, Go tests, `buf lint`, formatting and `git diff --check` pass. - Commit hooks pass, including gitleaks. CI status is reported by the checks; CodeQL is currently skipped by the repository workflow. ## Security considerations The browser fixture always creates its own database, including when a developer `DATABASE_URL` is inherited. It restores overridden environment values, shuts down resources in reverse order and sends mail only to the loopback TLS fixture. Self-signed HTTPS acceptance is confined to the isolated browser context. Browser requests to other origins are blocked. No traces, HAR files or screenshots are recorded; private fill failures and accessibility assertions avoid serializing credentials. No new product mutation or audit path is introduced. Development-only dependencies: Playwright 1.64.1 (Apache-2.0) and @axe-core/playwright 4.14.0 (MPL-2.0), pinned in manifests and lockfile. Password-reset, MFA/recovery and token-management browser workflows, failure/retry/private-grant checks, manual visual/accessibility inspection and design documentation remain explicitly unchecked in PLAN M2.2e4b2/M2.2e4c. Automated accessibility checks do not establish full WCAG conformance. This is the final PR in the current work session, as requested. ## Checklist - [x] M2.2e4b1 acceptance criteria met and marked in PLAN - [x] Lint, TS tests, Go tests and `buf lint` pass locally - [x] Browser security rejection checks and production-build regression added - [x] No new shell invocation or secret exposure path - [x] Existing audited state-changing paths exercised without modification - [x] README documents execution, isolation and remaining coverage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Production now serves the Angular build from the API process, matching ADR 0009 and keeping cookie/CSRF requests on one origin. The default directory is dist/apps/web/browser; WEB_DIST_DIR supports packaged layouts. Missing/invalid builds fail startup with opaque diagnostics and close the application. The OpenAPI-only generator still needs no web build.
Serving uses a bounded startup snapshot of public asset types, with no request-time filesystem path resolution. API paths, dotfiles, maps, metadata and traversal targets never become SPA responses. Hashed bundles are immutable; index HTML is no-store with a fresh CSP nonce. Inline build scripts/styles are disabled, and the web CSP allows same-origin assets, nonce-bound component styles and Angular's reviewed Trusted Types policies.
Validation: API/web lint, typecheck, tests and builds pass (102 API unit tests, 50 Angular tests). Five new real-HTTP tests cover nonces/cache headers, GET/HEAD navigation, API boundaries, forbidden files/traversal, snapshots, symlinks and size limits. The actual production index contains no inline script/style and retains its nonce placeholder. Real-browser CSP/identity acceptance follows in M2.2e4b. No new dependency.
The development example/docs now use the actual browser origin on port 4200; existing .env files must update that setting as documented. Stacked on #71. This PR stays draft until browser acceptance; no merge requested.