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
@@ -2,7 +2,10 @@ import type { ThemeConfig } from './theme.js'
|
||||
|
||||
import { themeScript } from './theme.js'
|
||||
|
||||
export type ThemeScriptProps = Partial<Pick<ThemeConfig, 'allowToggle' | 'defaultTheme'>>
|
||||
export type ThemeScriptProps = {
|
||||
/** CSP nonce (createProxy `csp` → `x-nonce` header) — needed when the policy uses nonces. */
|
||||
nonce?: string
|
||||
} & Partial<Pick<ThemeConfig, 'allowToggle' | 'defaultTheme'>>
|
||||
|
||||
/**
|
||||
* Sets the theme on <html> BEFORE anything is painted — no flash of the light
|
||||
@@ -12,6 +15,7 @@ export type ThemeScriptProps = Partial<Pick<ThemeConfig, 'allowToggle' | 'defaul
|
||||
* const shell = await getSiteShell(locale)
|
||||
* <html lang={locale} suppressHydrationWarning><body><ThemeScript {...shell.theme} />…
|
||||
*/
|
||||
export function ThemeScript({ allowToggle = false, defaultTheme = null }: ThemeScriptProps) {
|
||||
return <script dangerouslySetInnerHTML={{ __html: themeScript({ allowToggle, defaultTheme }) }} />
|
||||
export function ThemeScript({ allowToggle = false, defaultTheme = null, nonce }: ThemeScriptProps) {
|
||||
// suppressHydrationWarning: browsers hide the nonce attribute from the DOM (nonce hiding).
|
||||
return <script dangerouslySetInnerHTML={{ __html: themeScript({ allowToggle, defaultTheme }) }} nonce={nonce} suppressHydrationWarning />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user