fix(web): add Content-Security-Policy header to bunyip-web responses (BUNYIP-232) #260

Merged
Claude-Run merged 1 commit from fix/bunyip-232-web-csp-header into main 2026-06-28 03:07:39 +02:00
Member

bunyip-web emitted every security header except Content-Security-Policy (the edge proxy stamps HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy and Permissions-Policy but no CSP). Add a tower-http SetResponseHeaderLayer that stamps a CSP scoped to what the Maud + htmx SSR pages actually load: inline scripts/styles and onclick handlers ('unsafe-inline'), htmx from unpkg.com, the Font Awesome kit, the Google Fonts stylesheet/font CDNs, and the browser-facing bunyip-api origin in connect-src so the dashboard EventSource is not blocked. frame-ancestors 'none' and form-action 'self' lock down framing and form posts; SSO works because it is driven by top-level navigations, which CSP does not constrain.

The layer uses if_not_present so it does not clobber the admin attachment route's stricter Content-Security-Policy: sandbox. Adds tests asserting the CSP is present on responses, carries the expected directives, and leaves a handler-set policy untouched.

#BUNYIP-232

bunyip-web emitted every security header except Content-Security-Policy (the edge proxy stamps HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy and Permissions-Policy but no CSP). Add a tower-http SetResponseHeaderLayer that stamps a CSP scoped to what the Maud + htmx SSR pages actually load: inline scripts/styles and onclick handlers ('unsafe-inline'), htmx from unpkg.com, the Font Awesome kit, the Google Fonts stylesheet/font CDNs, and the browser-facing bunyip-api origin in connect-src so the dashboard EventSource is not blocked. frame-ancestors 'none' and form-action 'self' lock down framing and form posts; SSO works because it is driven by top-level navigations, which CSP does not constrain. The layer uses if_not_present so it does not clobber the admin attachment route's stricter Content-Security-Policy: sandbox. Adds tests asserting the CSP is present on responses, carries the expected directives, and leaves a handler-set policy untouched. #BUNYIP-232
fix(web): add Content-Security-Policy header to bunyip-web responses (BUNYIP-232)
All checks were successful
E2E / Playwright against deployment (pull_request) Successful in 21s
Check / fmt + clippy + build + tests (pull_request) Successful in 18m20s
Create release / Create release from merged PR (pull_request) Has been skipped
d23d469cbd
bunyip-web emitted every security header except Content-Security-Policy (the edge proxy stamps HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy and Permissions-Policy but no CSP). Add a tower-http SetResponseHeaderLayer that stamps a CSP scoped to what the Maud + htmx SSR pages actually load: inline scripts/styles and onclick handlers ('unsafe-inline'), htmx from unpkg.com, the Font Awesome kit, the Google Fonts stylesheet/font CDNs, and the browser-facing bunyip-api origin in connect-src so the dashboard EventSource is not blocked. frame-ancestors 'none' and form-action 'self' lock down framing and form posts; SSO works because it is driven by top-level navigations, which CSP does not constrain.

The layer uses if_not_present so it does not clobber the admin attachment route's stricter Content-Security-Policy: sandbox. Adds tests asserting the CSP is present on responses, carries the expected directives, and leaves a handler-set policy untouched.

#BUNYIP-232
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/bunyip!260
No description provided.