Consent: withdrawal clears tool cookies, policy version, consent log, cookie scan; form input hardening
Consent (GDPR)
- Withdrawing consent now deletes GA/Meta/Ads/Clarity/LinkedIn/TikTok/Hotjar
cookies (prefix patterns) on the host AND parent domains — previously only
the locale cookie was removed and _ga & co. stayed. Projects extend the list
via <ConsentProvider cookieMap>, merged with the defaults.
- Cookie Settings → Policy version: raising it asks every visitor again.
- <CookieBanner equalChoice>: Reject styled like Accept (UODO/EDPB), opt-in.
- Opt-in consent log (ipalKit({ consentLog: true }) + logEndpoint): random id,
choices, version, time — no IP/UA; admin-only collection, retention purge.
- Cookie Settings → Cookies + getCookieTable + unstyled <CookieTable> (/rsc).
- Consent cookie gets Secure on HTTPS; consent id stored with the decision.
- ipal-consent-check: cookie-scan.mjs (before/after consent, known-tool
catalog PL/EN, flags non-necessary cookies set before consent) and
import-cookies.ts into the panel (idempotent, keeps editor edits).
Forms
- Server-side type checks per field from the panel definition: email = one
address (blocks "a@x, b@y" recipient injection into {{email}} confirmations
and CR/LF header injection), select/radio only configured options, numbers,
booleans; objects/arrays rejected; control and bidi characters stripped.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -6,7 +6,7 @@ import type { ConsentTexts } from './texts.js'
|
||||
import { resolveLocalized } from '../i18n/resolveLocalized.js'
|
||||
import { getSystemPagePath } from '../pages/index.js'
|
||||
import { getGlobal } from '../payload/index.js'
|
||||
import { CONSENT_CATEGORIES } from './categories.js'
|
||||
import { CONSENT_CATEGORIES, type ConsentCategory } from './categories.js'
|
||||
|
||||
/** English fallback used when the global has no value for a field. */
|
||||
const FALLBACK: ConsentTexts = {
|
||||
@@ -39,7 +39,9 @@ const FALLBACK_PRIVACY_LABEL = 'Privacy policy'
|
||||
type CookieSettingsData = {
|
||||
buttons?: null | Partial<ConsentTexts['buttons']>
|
||||
categories?: Array<{ description?: null | string; key: string; title?: null | string }> | null
|
||||
cookies?: Array<{ category?: null | string; duration?: null | string; name?: null | string; provider?: null | string; purpose?: null | string }> | null
|
||||
message?: null | string
|
||||
policyVersion?: null | number
|
||||
privacyLinkLabel?: null | string
|
||||
settingsTitle?: null | string
|
||||
}
|
||||
@@ -141,5 +143,35 @@ export async function getConsentTexts({
|
||||
message: g.message || FALLBACK.message,
|
||||
privacyLink,
|
||||
settingsTitle: g.settingsTitle || FALLBACK.settingsTitle,
|
||||
...(typeof g.policyVersion === 'number' && g.policyVersion >= 1 ? { version: Math.trunc(g.policyVersion) } : {}),
|
||||
}
|
||||
}
|
||||
|
||||
export type CookieTableRow = {
|
||||
category: ConsentCategory
|
||||
duration?: string
|
||||
name: string
|
||||
provider?: string
|
||||
purpose?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Rows of Cookie Settings → Cookies in one language, for the cookie policy page
|
||||
* (<CookieTable rows={…}>). Server-side; never throws (empty list).
|
||||
*/
|
||||
export async function getCookieTable({ locale, payload }: { locale?: string; payload: BasePayload }): Promise<CookieTableRow[]> {
|
||||
try {
|
||||
const g = await getGlobal<CookieSettingsData>(payload, 'cookie-settings', { locale })
|
||||
return (g.cookies ?? [])
|
||||
.filter((c) => typeof c.name === 'string' && c.name.trim())
|
||||
.map((c) => ({
|
||||
name: c.name!.trim(),
|
||||
category: (CONSENT_CATEGORIES as readonly string[]).includes(c.category ?? '') ? (c.category as ConsentCategory) : 'necessary',
|
||||
...(c.provider?.trim() ? { provider: c.provider.trim() } : {}),
|
||||
...(c.purpose?.trim() ? { purpose: c.purpose.trim() } : {}),
|
||||
...(c.duration?.trim() ? { duration: c.duration.trim() } : {}),
|
||||
}))
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user