File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,26 @@ method to check its validity::
164
164
}
165
165
}
166
166
167
+ Alternatively you can use the
168
+ :class: `Symfony\\ Component\\ Security\\ Http\\ Attribute\\ IsCsrfTokenValid `
169
+ attribute on the controller action::
170
+
171
+ use Symfony\Component\HttpFoundation\Request;
172
+ use Symfony\Component\HttpFoundation\Response;
173
+ use Symfony\Component\Security\Http\Attribute\IsCsrfTokenValid;
174
+ // ...
175
+
176
+ #[IsCsrfTokenValid('delete-item', tokenKey: 'token')]
177
+ public function delete(Request $request): Response
178
+ {
179
+ // ... do something, like deleting an object
180
+ }
181
+
182
+ .. versionadded :: 7.1
183
+
184
+ The :class: `Symfony\\ Component\\ Security\\ Http\\ Attribute\\ IsCsrfTokenValid `
185
+ attribute was introduced in Symfony 7.1.
186
+
167
187
CSRF Tokens and Compression Side-Channel Attacks
168
188
------------------------------------------------
169
189
You can’t perform that action at this time.
0 commit comments