Add support for Django 6.0 built-in Content Security Policy#431
Open
alimony wants to merge 1 commit intoIdentityPython:masterfrom
Open
Add support for Django 6.0 built-in Content Security Policy#431alimony wants to merge 1 commit intoIdentityPython:masterfrom
alimony wants to merge 1 commit intoIdentityPython:masterfrom
Conversation
Django 6.0 ships with native Content Security Policy support via `ContentSecurityPolicyMiddleware`. When `django-csp` is not installed, `djangosaml2` now detects the native CSP middleware and uses `csp_override` to merge `form-action: https:` into the existing `SECURE_CSP` settings. Detection order: `django-csp` → Django native CSP → warning + no-op.
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.
Summary
django-cspis not installedSECURE_CSPsettings, mergeform-action: ["https:"], and apply viacsp_overridedjango-cspis still tried firstContext
Django 6.0 introduced native CSP support via
ContentSecurityPolicyMiddlewareand
SECURE_CSPsettings. Previously, djangosaml2 only detecteddjango-cspforautomatic CSP configuration. Users on Django 6.0 using the built-in CSP had to
either install
django-cspor configure a customSAML_CSP_HANDLER.Since Django's built-in CSP only provides
csp_override(full replacement, nomerge), the implementation reads the existing
SECURE_CSPdict, addsform-action: https:to it, and applies the merged config viacsp_override.