Skip to content

feat: enforce CSP in debug by default with opt-out flag#1702

Merged
davidpoblador merged 1 commit into
mainfrom
worktree-jazzy-dancing-zephyr
Apr 27, 2026
Merged

feat: enforce CSP in debug by default with opt-out flag#1702
davidpoblador merged 1 commit into
mainfrom
worktree-jazzy-dancing-zephyr

Conversation

@davidpoblador

Copy link
Copy Markdown
Member

Summary

  • Adds enforce_csp_in_debug: bool = True to SecurityHeadersSettings (env: CSP_ENFORCE_CSP_IN_DEBUG).
  • SecurityHeadersMiddleware now emits Content-Security-Policy-Report-Only only when settings.debug is true and the new flag is false. Default flips so CSP violations break the page locally.
  • Updates docs (development-guide.md, llms.txt, llms-full.txt) and the scaffolded-project rule (vibetuner-template/.claude/rules/configuration.md).

Closes #1701

Test plan

  • uv run python -m pytest tests/unit/test_security_headers_middleware.py — 25/25 pass, including new test_enforced_header_in_debug_mode_by_default, test_report_only_header_when_debug_opts_out, and test_production_ignores_enforce_csp_in_debug_flag.
  • Full unit suite (uv run python -m pytest tests/) — 695 pass.
  • uv run ruff check and ruff format --check clean on touched files.
  • just lint-md clean.

🤖 Generated with Claude Code

Adds `CSP_ENFORCE_CSP_IN_DEBUG` (default `true`) so CSP violations break
the page locally instead of only being reported. Set to `false` to keep
the legacy `Content-Security-Policy-Report-Only` behavior in debug.

Closes #1701

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@davidpoblador davidpoblador merged commit 2d939ea into main Apr 27, 2026
@davidpoblador davidpoblador deleted the worktree-jazzy-dancing-zephyr branch April 27, 2026 09:05
davidpoblador pushed a commit that referenced this pull request Apr 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[10.6.0](v10.5.0...v10.6.0)
(2026-04-28)


### Features

* enforce CSP in debug by default with opt-out flag
([#1702](#1702))
([2d939ea](2d939ea))
* per-tenant theming via runtime CSS-variable injection
([#1707](#1707))
([6a44e6c](6a44e6c))


### Miscellaneous Chores

* add `vibetuner core-templates-path` CLI for setup-tw-sources
([#1708](#1708))
([b095d32](b095d32))
* **deps:** bump gitpython from 3.1.46 to 3.1.47
([#1689](#1689))
([b44149d](b44149d))
* **deps:** bump gitpython from 3.1.46 to 3.1.47 in /vibetuner-py
([#1688](#1688))
([14aaf96](14aaf96))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

Add a flag to enforce CSP locally instead of report-only

1 participant