File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ class Form extends Nette\Forms\Form implements ISignalReceiver
20
20
/** @var callable[]&(callable(Form $sender): void)[]; Occurs when form is attached to presenter */
21
21
public $ onAnchor ;
22
22
23
+ /** @var bool */
24
+ private $ sameSiteProtection = true ;
25
+
23
26
24
27
/**
25
28
* Application form constructor.
@@ -97,6 +100,15 @@ public function isAnchored(): bool
97
100
}
98
101
99
102
103
+ /**
104
+ * Disables CSRF protection using a SameSite cookie.
105
+ */
106
+ public function disableSameSiteProtection (): void
107
+ {
108
+ $ this ->sameSiteProtection = false ;
109
+ }
110
+
111
+
100
112
/**
101
113
* Internal: returns submitted HTTP data or null when form was not submitted.
102
114
*/
@@ -143,7 +155,7 @@ public function signalReceived(string $signal): void
143
155
$ class = get_class ($ this );
144
156
throw new BadSignalException ("Missing handler for signal ' $ signal' in $ class. " );
145
157
146
- } elseif (!$ this ->getPresenter ()->getHttpRequest ()->isSameSite ()) {
158
+ } elseif ($ this -> sameSiteProtection && !$ this ->getPresenter ()->getHttpRequest ()->isSameSite ()) {
147
159
$ this ->getPresenter ()->detectedCsrf ();
148
160
149
161
} elseif (!$ this ->getPresenter ()->getRequest ()->hasFlag (Nette \Application \Request::RESTORED )) {
You can’t perform that action at this time.
0 commit comments