Repository navigation
docs: add Events security notes for HEAD, redirects, and data classes - #752
Merged
Merged
Conversation
- Say that a handler accepting HEAD or OPTIONS, including a ViewEvents head or options method, skips Django's CSRF token check and must only read data. - Show how a Flask or FastAPI app can call Django's redirect URL check, and which URL forms a hand-written check must refuse. - Add short notes on the __Host- CSRF cookie name and on blocking page framing with frame-ancestors. - Note that a Pydantic model data class accepts "5" for an int and drops unknown fields, and that RouteResponse headers are unchecked. - Dispatch: choose the name in app code; in Firefox a submit event on a form root also submits the form. - format_attrs: name Citry's marker names in the rule. Closes #700 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
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.
What changed
Docs and two docstrings. No code behavior changes.
HEADandOPTIONShandlers (security.md,events/routes.md, both migration guides). These are read-only methods in HTTP, and Django's CSRF token check skips them. Citry still runs its own header checks and any_csrffunction. A handler that acceptsHEADorOPTIONSmust only read data, and that includes aheadoroptionsmethod on aViewEventsclass. The section heading is now "KeepGET,HEADread-only", and its anchor stays the same. The component-view guide's sentence "Django's CSRF middleware still applies" now has a separate warning about these methods next to it.security.md, theRedirectwarning inevents/actions.md). Flask and FastAPI apps can call Django'surl_has_allowed_host_and_scheme, because it needs no Django settings. A hand-written check must read the URL as written and again with\changed to/. The page lists the URL forms that a check based only onurlsplit().hostnamelets through. Citry's own redirect handling is unchanged.__Host-CSRF cookie name under "Use Django's token": the Django settings and theCitry.configurecall it needs, and what fails if the call is missing.X-Frame-Optionsandframe-ancestors.dataclasses accept"5"andtruefor anintand drop unknown fields, while dataclasses and plain classes refuse them. The page says how to refuse unknown fields withextra="forbid", and whystrict=Truebreaks form posts.RouteResponsefrom abundle=Falsehandler: a new section, "Send your own response". Citry does not check its header names, header values, orcontent_type.Dispatch(Decide whether Dispatch refuses names of standard DOM events #704): the docstring and docs page say the name must come from app code. They also say that in Firefox asubmitevent on a form root submits the form. Decide whether Dispatch refuses names of standard DOM events #704 stays open for the planned deprecation.format_attrs(Decide whether format_attrs refuses the names c-bind refuses #700): the docstring and the HTML attributes page now name Citry's marker names in the rule. Thetrust_boundaries.mdrows forformat_attrs,DispatchandRouteResponseare updated, and the Decide whether format_attrs refuses the names c-bind refuses #700 open-question row is removed.Closes #700
Checks
main. I also ran probes against citry 1.0.1, Pydantic 2.14.3 and Django 6.1.3:settings.configure(), on 13 URL forms;model_baseandstrict=Truebinding, throughvalidate_args;format_attrswith marker names.submitbehavior in Firefox, Chromium and WebKit builds.ruff checkandruff format --checkpass on the two Python files.HEADwording that names_csrf;OPTIONScovered on every page;///URL forms added;__Host-cookie needs onDomainandPath;RouteResponsenotes in their own sections;Versioning
Nothing the 1.x promise covers changes. The change only edits docs and docstrings, so it needs no changelog entry.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED