Repository navigation
chore: cherry-pick 2 PRs to 25.4 (CP: 25.4) - #27692
Open
vaadin-bot wants to merge 2 commits into
Open
vaadin-bot wants to merge 2 commits into
vaadin-bot wants to merge 2 commits into
Conversation
… mode (#27612) (CP: 25.4) Part of #26696 Follow-up to #27471 **new feature** · flow-server, vaadin-spring · apps that use `contentSecurityPolicy=warn`, or `strict` in development mode **Background — report-only policy.** A `Content-Security-Policy-Report-Only` header makes the browser check the page against a policy and report every violation, in the console and to a `report-uri`/`report-to` collector, without blocking anything. Vaadin now sends its strict policy, with the nonce on its scripts, as report-only wherever it does not enforce it: in the `warn` mode, in development and production mode, and in the `strict` mode in development mode. The browser then shows what the enforced policy would block, such as inline scripts, `eval` in client code and resources from other origins, which the server-side checks cannot see. `strict` in production mode enforces the same policy, as before. **Risks:** -⚠️ Behaviour change: pages in `warn` mode, and in `strict` mode in development mode, now get a `Content-Security-Policy-Report-Only` header and a nonce on their scripts. The browser console shows the violations; nothing is blocked. -⚠️ Behaviour change: in development mode, the console also shows two reports that do not come from the app: the `eval` of the web components' development mode detector, and, with Vite, the inline `onerror` reload handler that Flow puts on the dev mode script. Both are tracked in #27627. -⚠️ Behaviour change: in `warn` mode, `IndexHtmlResponse.getContentSecurityPolicy()` and `getContentSecurityPolicyNonce()` now return a value instead of `null`. - ✅ No change in `off` mode, in `strict` mode in production mode, or when a security framework provides the nonce. **Context.** Follows the decisions of #27471: when a security framework such as Spring Security provides the nonce, Vaadin uses it in every mode and sends no policy of its own. With Spring Security, the app sends the policy as report-only through `vaadin().contentSecurityPolicy(policy -> {}, config -> config.reportOnly())`. No built-in endpoint for the reports is added. The policy is only enforced in `strict` production mode, because the dev server and the dev tools need `eval`; a report-only policy blocks nothing, so it is sent in development mode. - `IndexHtmlRequestHandler` creates the nonce and the policy in `warn` mode too, and sends the policy as `Content-Security-Policy-Report-Only` except in `strict` production mode, where it sends `Content-Security-Policy` - A report-only header that the response already has is kept, and a warning naming the mode is logged once per handler, so a report-only policy never fails the request - An enforced `Content-Security-Policy` header of the app is left alone when the policy is report-only; `strict` production mode still fails the request for it - Updated the Javadoc of `ContentSecurityPolicyMode`, `IndexHtmlResponse`, `ContentSecurityPolicy` and `VaadinSecurityConfigurer.contentSecurityPolicy()` - The tests of the sent policy now also cover `warn` in production and development mode and `strict` in development mode; the test that no policy is sent now only covers `off`, since `warn` and `strict` development mode send one Working on behalf of @mcollovati --------- Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com> Co-authored-by: Artur Signell <artur@vaadin.com> Co-authored-by: caalador <mikael.grankvist@vaadin.com> Co-authored-by: Giovanni Lovato <giovanni@vaadin.com> Co-authored-by: Marco Collovati <marco@vaadin.com>
Resolution notes: - .github/workflows/README.md: conflicts were only the Diagram Bot table row and section; resolved by removing both, as the original PR does. - diagram-bot.md and diagram-bot.lock.yml (modify/delete conflicts, the 25.4 copies differ slightly from main): deleted, as the original PR does. - No tests are affected. The formatter and the Maven build were not run because the pick changes only CI workflow files and docs, no module sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Auto merge (with 'rebase' method) is enabled for this PR, so it is merged once it is approved and its checks pass. Please review it and approve it, do not merge it manually. [Message is sent from bot] |
Collaborator
Author
|
Auto merge (with 'rebase' method) is enabled for this PR, so it is merged once it is approved and its checks pass. Please review it and approve it, do not merge it manually. [Message is sent from bot] |
Contributor
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This PR cherry-picks 2 PRs to branch 25.4, one commit each, in the order they were merged:
Merge it with rebase and merge, so that each pick keeps its own commit.
Warning
The cherry-pick had merge conflicts that were resolved automatically by Claude Code. Please review the changes carefully.
Resolution notes from Claude:
#27575: