Skip to content

Cookbook: security headers and cross-origin resource sharing - #641

Merged
dex4er merged 1 commit into
cors-pluginfrom
security-headers-cookbook
Nov 18, 2026
Merged

dex4er merged 1 commit into
cors-pluginfrom
security-headers-cookbook

Conversation

@dex4er

@dex4er dex4er commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Part of #634, its sixth step, stacked on #640.

Changes

  • New cookbook recipe Security headers, after Hosts and origins:
    • enabling SecurityHeaders with its defaults
    • HSTS: start with a few minutes, then include_subdomains and preload only once every subdomain has HTTPS
    • CSP: try a policy out with csp_report_only and the route of reports, then move it to csp
    • the nonce and its Cache-Control: private on a CDN
    • the hook csp_report
    • what Permissions-Policy and the other headers do
  • New cookbook recipe Cross-origin resource sharing: plugin('CORS'), a frontend on its own site with credentials, with the same origins in AllowedHosts, and what CORS does not protect (posts, which CSRF protection is for).
  • The JSONP recipe links to the CORS recipe instead of Hosts and origins.
  • Examples docs/guides/cookbook/security_headers.py and docs/guides/cookbook/cors.py, which the pages include and t/docs/guides_cookbook.py tests.

Validation

  • t/docs/guides_cookbook.py:
    • Security headers: the headers of the example, the nonce of its inline script, a report, the hook
    • Cross-origin resource sharing: a request and a preflight of the two origins, 403 for another origin, no CORS headers outside /api
  • t/docs/guides_index.py
  • sphinx-build -W passes
  • trunk check: no issues
  • CI

🤖 Generated with Claude Code

Recipes of Pyjoyment.Plugin.SecurityHeaders, with the rollout of HSTS and of
a CSP from its reports, the nonce and the hook csp_report, and of
Pyjoyment.Plugin.CORS with AllowedHosts, with tested examples.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dex4er dex4er added this to the 0.4.1 milestone Nov 18, 2026
@dex4er
dex4er added this pull request to stack #637 November 18, 2026 17:26
@read-the-docs-community

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Tests

Job Tests Passed ✅ Skipped ⚠️ Failed ❌ Log
prove (python 3.12, Asyncio) 7515 7486 29 0 ✅ 134993977802
prove (python 3.12, Poll) 7487 7456 31 0 ✅ 134993977864
prove (python 3.13, Asyncio) 7515 7486 29 0 ✅ 134993978410
prove (python 3.13, Poll) 7487 7456 31 0 ✅ 134993977865
prove (python 3.14, Asyncio) 7546 7522 24 0 ✅ 134993977855
prove (python 3.14, Poll) 7518 7492 26 0 ✅ 134993977957
prove (python 3.15, Asyncio) 7546 7522 24 0 ✅ 134993978091
prove (python 3.15, Poll) 7518 7492 26 0 ✅ 134993977986
prove (python 3.15t, Asyncio) 7546 7522 24 0 ✅ 134993978217
prove (python 3.15t, Poll) 7518 7492 26 0 ✅ 134993978241
prove (python mise, Asyncio) 7625 7590 35 0 ✅ 134993977854
prove (python mise, Asyncio, Windows) 7346 7280 66 0 ✅ 134993978259
prove (python mise, Poll) 7597 7560 37 0 ✅ 134993977978
prove (python mise, Poll, Windows) 7318 7250 68 0 ✅ 134993977894
prove (python pypy3.12, Asyncio) 7515 7486 29 0 ✅ 134993978661
prove (python pypy3.12, Poll) 7487 7456 31 0 ✅ 134993977995
pytest (python 3.12, ubuntu-26.04-arm) 446 420 26 0 ✅ 134993977698
pytest (python 3.15, ubuntu-26.04-arm) 446 425 21 0 ✅ 134993978150
pytest (python 3.15, windows-2025) 446 397 49 0 ✅ 134993977964
servers (python 3.12) 54 54 0 0 ✅ 134993977808
servers (python 3.15) 53 53 0 0 ✅ 134993977229
All 121529 120897 632 0 ✅

The run of the workflow

@dex4er dex4er modified the milestones: 0.4.1, 0.5.0 Nov 18, 2026
@dex4er
dex4er merged commit 275b1aa into main Nov 18, 2026
26 checks passed
@dex4er
dex4er deleted the security-headers-cookbook branch November 18, 2026 21:20
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.

1 participant