File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -52,3 +52,5 @@ query_path=query
5252csrf_header =X-CSRF
5353; csrf_ignore_path=/test-csrf-ignore,/test/*/wildcard/,/another-test-ignore
5454csrf_ignore_path =
55+ csrf_max_tokens =100
56+ csrf_token_length =10
Original file line number Diff line number Diff line change @@ -197,13 +197,14 @@ public function handle(
197197 $ serviceContainer ->set ($ session );
198198
199199 $ session = $ serviceContainer ->get (Session::class);
200- $ csrfTokenStore = new SessionTokenStore (
201- $ session ->getStore ("webengine.csrf " , true )
202- );
203200
204201 $ shouldVerifyCsrf = true ;
205202 $ ignoredPathArray = explode (", " , $ this ->config ->getString ("security.csrf_ignore_path " ) ?? "" );
206203 foreach ($ ignoredPathArray as $ ignoredPath ) {
204+ if (empty ($ ignoredPath )) {
205+ continue ;
206+ }
207+
207208 if (str_contains ($ ignoredPath , "* " )) {
208209 $ pattern = strtr (rtrim ($ ignoredPath , "/ " ), [
209210 "* " => ".* " ,
@@ -220,6 +221,14 @@ public function handle(
220221 }
221222
222223 if ($ shouldVerifyCsrf ) {
224+ $ csrfTokenStore = new SessionTokenStore (
225+ $ session ->getStore ("webengine.csrf " , true ),
226+ $ this ->config ->getInt ("security.csrf_max_tokens " )
227+ );
228+ $ csrfTokenStore ->setTokenLength (
229+ $ this ->config ->getInt ("security.csrf_token_length " )
230+ );
231+
223232 if ($ request ->getMethod () === "POST " ) {
224233 $ csrfTokenStore ->verify ($ _POST );
225234 }
You can’t perform that action at this time.
0 commit comments