feat: centralize CSP handling and add controller decorators to support customization#22980
Open
feat: centralize CSP handling and add controller decorators to support customization#22980
Conversation
…ors to support customization
teleivo
reviewed
Feb 25, 2026
teleivo
reviewed
Feb 25, 2026
|
teleivo
approved these changes
Feb 26, 2026
|
|
||
| // Verify custom policy directives are in the CSP header | ||
| assertTrue( | ||
| cspHeader.contains("default-src 'self'"), |
Contributor
There was a problem hiding this comment.
assertEquals gives better error messages in case this breaks. Right now you just get expected true got false
Comment on lines
55
to
57
| @Component | ||
| @RequiredArgsConstructor | ||
| public class RequestHandler { |
Contributor
There was a problem hiding this comment.
Suggested change
| public class RequestHandler { |
this class can now be a utility one with static methods as it has no dependencies
netroms
approved these changes
Mar 5, 2026
| POSTGRES_USER: ${DB_USERNAME} | ||
| POSTGRES_DB: ${DB_NAME:-dhis} | ||
| POSTGRES_PASSWORD: &postgres_password ${DB_USERNAME} | ||
| POSTGRES_PASSWORD: &postgres_password ${DB_PASSWORD} |
Contributor
There was a problem hiding this comment.
Is this relevant for this PR?
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 centralizes and standardizes CSP handling. All CSP headers (except certain Tracker exceptions) are set in the new
CspInterceptor, which applies the default CSP policy to all endpoints and can be overridden with the new annotation@CspUserUploadedContentor@CustomCsp.Previously these headers were inconsistently set, inconsistently overridable in configuration, and difficult to audit since they were often set manually in individual controllers. See this doc for current state analysis.
Future improvements: system setting overrides for these settings, per-application Csp settings declared in manifest and able to be approved/denied by app admins.