Repository navigation
docs: correct CSRF protection opt-in description - #30
Merged
Merged
Conversation
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
The README sections on CSRF protection claimed that
SetAntiCsrfTraitonly wiresAntiCsrfInterfaceinto the form and that token verification requires#[CsrfProtection]:This is not what the code does.
SetAntiCsrfTrait::setAntiCsrf()is annotated with#[Inject], so DI populates$this->antiCsrfat construction.AbstractForm::postConstruct()then callsenableAntiCsrf()to add the token field, andAbstractForm::apply()throwsCsrfViolationExceptionon token mismatch — regardless of whether the controller method has#[CsrfProtection]. This is exercised byAbstractFormTest::testAntiCsrfViolation, which sets antiCsrf directly on the form (no interceptor, no attribute) and asserts the throw.So there are two independent opt-in paths and the README/skill should describe them as such.
Changes
README.md/README.JA.md: rewrite the "CSRF Protections" intro to describe the two independent paths (per-form trait vs. per-action attribute) and state that either causesapply()to throw on mismatch..claude/skills/migrate-to-1.0/SKILL.md: replace the "out of scope" bullet that said forms usingSetAntiCsrfTraitwithout#[CsrfProtection]"will silently stop enforcing CSRF in 1.0" — the actual at-risk case is the removed@FormValidation(antiCsrf=true)option when the form did not also use the trait.Test plan
use SetAntiCsrfTrait;+ no#[CsrfProtection]on controller) is consistent withAbstractFormTest::testAntiCsrfViolation.Generated by Claude Code
Summary by CodeRabbit