File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -345,6 +345,8 @@ Anti-CSRF Config Options
345345 'default' => [
346346 'enabled' => true,
347347 'token_name' => 'csrf_token',
348+ 'token_bytes_length' => 8,
349+ 'generate_token_function' => 'base64_encode',
348350 'session_instance' => 'default',
349351 'request_instance' => 'default',
350352 ],
@@ -361,6 +363,18 @@ token_name
361363
362364Sets the token name. The default is ``csrf_token ``.
363365
366+ token_bytes_length
367+ """"""""""""""""""
368+
369+ Sets the length of random bytes used to generate the token. The default is
370+ ``8 ``.
371+
372+ generate_token_function
373+ """""""""""""""""""""""
374+
375+ Sets the function to generate the token. Available values are:
376+ ``base64_encode ``, ``bin2hex ``, ``md5 ``. The default is ``base64_encode ``.
377+
364378session_instance
365379""""""""""""""""
366380
Original file line number Diff line number Diff line change @@ -663,7 +663,11 @@ protected static function setAntiCsrf(string $instance) : AntiCSRF
663663 {
664664 $ config = static ::config ()->get ('antiCsrf ' , $ instance );
665665 static ::session ($ config ['session_instance ' ] ?? 'default ' );
666- $ service = new AntiCSRF (static ::request ($ config ['request_instance ' ] ?? 'default ' ));
666+ $ service = new AntiCSRF (
667+ static ::request ($ config ['request_instance ' ] ?? 'default ' ),
668+ $ config ['token_bytes_length ' ] ?? null ,
669+ $ config ['generate_token_function ' ] ?? null ,
670+ );
667671 if (isset ($ config ['token_name ' ])) {
668672 $ service ->setTokenName ($ config ['token_name ' ]);
669673 }
Original file line number Diff line number Diff line change 1111 'default ' => [
1212 'enabled ' => false ,
1313 'token_name ' => 'csrf_token ' ,
14+ 'token_bytes_length ' => 8 ,
15+ 'generate_token_function ' => 'base64_encode ' ,
1416 ],
1517];
You can’t perform that action at this time.
0 commit comments