Security: hide X-Powered-By, CSP report-only with reports, admin policy and nonces
- withSecurityConfig: poweredByHeader false + strips X-Powered-By from headers()
(Next's and withPayload's), works on either side of withPayload
- buildSecurityHeaders({ csp }): CSP + Reporting-Endpoints; mode switches
report-only → enforce
- buildCsp: reportUri/reportGroup, nonce + strict-dynamic, dev unsafe-eval,
metaPixel/linkedIn/tiktok/clarity flags, media-src for R2, override
- buildAdminCsp(Headers): looser policy for Payload admin (Monaco CDN, blob workers)
- createCspReportRoute + parseCspReports: report collector for both formats
- createProxy({ csp }) + createCspNonce: per-request nonce, x-nonce header;
SiteProviders/ThemeScript/Analytics/ConsentScript accept nonce
- docs: security.md, AGENT.md, ipal-setup/reference/upgrade; ipal-audit checks
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
771dda1c6f
commit
ff4c595b91
@@ -0,0 +1,10 @@
|
||||
/** Request header the proxy uses to hand the nonce to server components. */
|
||||
export const CSP_NONCE_HEADER = 'x-nonce'
|
||||
|
||||
/**
|
||||
* A fresh per-request nonce (base64 of a random UUID, 128 bits of randomness).
|
||||
* Works in the Edge and Node runtimes (Web Crypto + btoa are globals in both).
|
||||
*/
|
||||
export function createCspNonce(): string {
|
||||
return btoa(crypto.randomUUID())
|
||||
}
|
||||
Reference in New Issue
Block a user