You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running a Vaadin application under a strict Content Security Policy (script-src 'nonce-…', no unsafe-inline, no unsafe-eval) needs one explicit switch that the rest of the strict-CSP work can key off, see vaadin/platform#9488.
Describe the solution you'd like
A csp configuration setting with three values:
off (default): exactly today's behaviour.
warn: the application runs unchanged, but every call that would not work under a strict policy is logged.
strict: Vaadin sends a nonce-based policy, and APIs that need eval throw.
It is configured like other Vaadin settings: servlet init parameter / system property (vaadin.csp) and the Spring Boot property, and exposed through DeploymentConfiguration so framework code can query the active mode.
This issue covers only the setting and its plumbing. The behaviour of warn and strict is tracked in separate sub-issues of the parent issue.
This is a valid, self-contained request: there is no CSP-related setting in Flow yet, and the later warn/strict behaviour needs a single switch to key off.
Flow already has a direct precedent for an enum-valued setting: sessionLockCheckStrategy / SessionLockCheckStrategy. It is an InitParameters constant, a default method on DeploymentConfiguration, and parsing in DefaultDeploymentConfiguration, where an unrecognized value logs a warning and falls back to the default. Following the same shape gives every requested configuration source for free:
servlet init parameter csp
system property / application property vaadin.csp (via getApplicationOrSystemProperty)
Spring Boot vaadin.csp: SpringServlet already forwards every InitParameters constant from the Spring environment, so no Spring-specific code is needed
Proposed change (draft PR follows)
New enum com.vaadin.flow.server.CspMode { OFF, WARN, STRICT }
InitParameters.CSP = "csp"
DeploymentConfiguration#getCspMode(): a default method that returns CspMode.OFF, so other DeploymentConfiguration implementations keep working unchanged
DefaultDeploymentConfiguration parses the value case-insensitively. An unknown value adds a warning (WARNING_CSP_MODE_NOT_RECOGNIZED) and falls back to OFF.
With the default off, behaviour does not change at all. Nothing reads the mode yet; warn/strict behaviour is left to the sibling sub-issues, as the issue describes.
Activity
totally-not-ai commentedon Oct 2, 2026
Analysis
This is a valid, self-contained request: there is no CSP-related setting in Flow yet, and the later
warn/strictbehaviour needs a single switch to key off.Flow already has a direct precedent for an enum-valued setting:
sessionLockCheckStrategy/SessionLockCheckStrategy. It is anInitParametersconstant, adefaultmethod onDeploymentConfiguration, and parsing inDefaultDeploymentConfiguration, where an unrecognized value logs a warning and falls back to the default. Following the same shape gives every requested configuration source for free:cspvaadin.csp(viagetApplicationOrSystemProperty)vaadin.csp:SpringServletalready forwards everyInitParametersconstant from the Spring environment, so no Spring-specific code is neededProposed change (draft PR follows)
com.vaadin.flow.server.CspMode { OFF, WARN, STRICT }InitParameters.CSP = "csp"DeploymentConfiguration#getCspMode(): a default method that returnsCspMode.OFF, so otherDeploymentConfigurationimplementations keep working unchangedDefaultDeploymentConfigurationparses the value case-insensitively. An unknown value adds a warning (WARNING_CSP_MODE_NOT_RECOGNIZED) and falls back toOFF.With the default
off, behaviour does not change at all. Nothing reads the mode yet;warn/strictbehaviour is left to the sibling sub-issues, as the issue describes.vaadin-bot commentedon Nov 6, 2026
This ticket/PR has been released with Vaadin 25.4.0-alpha5.
feat: add csp mode setting (off, warn, strict) (vaadin#26157)