Skip to content

WW-5504 Allows to use request instead of session attribute to store nonce#1352

Merged
lukaszlenart merged 1 commit into
mainfrom
feature/WW-5504-request-nonce-s7
Sep 24, 2025
Merged

WW-5504 Allows to use request instead of session attribute to store nonce#1352
lukaszlenart merged 1 commit into
mainfrom
feature/WW-5504-request-nonce-s7

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables using request attributes instead of session attributes to store CSP nonce values for improved flexibility in nonce management.

Key changes:

  • Added configuration option struts.csp.nonce.source to specify whether nonce values are stored in session or request scope
  • Introduced new CspNonceReader interface and StrutsCspNonceReader implementation to abstract nonce value retrieval
  • Modified DefaultCspSettings to support both session and request-based nonce generation

Reviewed Changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
core/src/main/java/org/apache/struts2/interceptor/csp/StrutsCspNonceReader.java New implementation for reading nonce values from either session or request attributes
core/src/main/java/org/apache/struts2/interceptor/csp/DefaultCspSettings.java Updated to support configurable nonce source and refactored nonce generation logic
core/src/main/java/org/apache/struts2/components/UIBean.java Modified to use the new CspNonceReader interface instead of direct session access
core/src/main/resources/org/apache/struts2/default.properties Added configuration property for nonce source selection
plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/*.java Updated test files to inject CspNonceReader dependencies

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread core/src/main/java/org/apache/struts2/interceptor/csp/DefaultCspSettings.java Outdated
Comment thread core/src/main/java/org/apache/struts2/interceptor/csp/DefaultCspSettings.java Outdated
@lukaszlenart lukaszlenart force-pushed the feature/WW-5504-request-nonce-s7 branch from bca2c9b to d557e8b Compare September 15, 2025 05:37
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
68.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@lukaszlenart lukaszlenart merged commit 1b43b53 into main Sep 24, 2025
8 of 9 checks passed
@lukaszlenart lukaszlenart deleted the feature/WW-5504-request-nonce-s7 branch September 24, 2025 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants