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
345
345
'default' => [
346
346
'enabled' => true,
347
347
'token_name' => 'csrf_token',
348
+ 'token_bytes_length' => 8,
349
+ 'generate_token_function' => 'base64_encode',
348
350
'session_instance' => 'default',
349
351
'request_instance' => 'default',
350
352
],
@@ -361,6 +363,18 @@ token_name
361
363
362
364
Sets the token name. The default is ``csrf_token ``.
363
365
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
+
364
378
session_instance
365
379
""""""""""""""""
366
380
Original file line number Diff line number Diff line change @@ -663,7 +663,11 @@ protected static function setAntiCsrf(string $instance) : AntiCSRF
663
663
{
664
664
$ config = static ::config ()->get ('antiCsrf ' , $ instance );
665
665
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
+ );
667
671
if (isset ($ config ['token_name ' ])) {
668
672
$ service ->setTokenName ($ config ['token_name ' ]);
669
673
}
Original file line number Diff line number Diff line change 11
11
'default ' => [
12
12
'enabled ' => false ,
13
13
'token_name ' => 'csrf_token ' ,
14
+ 'token_bytes_length ' => 8 ,
15
+ 'generate_token_function ' => 'base64_encode ' ,
14
16
],
15
17
];
You can’t perform that action at this time.
0 commit comments