Security.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace Config;
  3. use CodeIgniter\Config\BaseConfig;
  4. class Security extends BaseConfig
  5. {
  6. /**
  7. * --------------------------------------------------------------------------
  8. * CSRF Protection Method
  9. * --------------------------------------------------------------------------
  10. *
  11. * Protection Method for Cross Site Request Forgery protection.
  12. *
  13. * @var string 'cookie' or 'session'
  14. */
  15. public string $csrfProtection = 'cookie';
  16. /**
  17. * --------------------------------------------------------------------------
  18. * CSRF Token Randomization
  19. * --------------------------------------------------------------------------
  20. *
  21. * Randomize the CSRF Token for added security.
  22. */
  23. public bool $tokenRandomize = false;
  24. /**
  25. * --------------------------------------------------------------------------
  26. * CSRF Token Name
  27. * --------------------------------------------------------------------------
  28. *
  29. * Token name for Cross Site Request Forgery protection.
  30. */
  31. public string $tokenName = 'csrf_test_name';
  32. /**
  33. * --------------------------------------------------------------------------
  34. * CSRF Header Name
  35. * --------------------------------------------------------------------------
  36. *
  37. * Header name for Cross Site Request Forgery protection.
  38. */
  39. public string $headerName = 'X-CSRF-TOKEN';
  40. /**
  41. * --------------------------------------------------------------------------
  42. * CSRF Cookie Name
  43. * --------------------------------------------------------------------------
  44. *
  45. * Cookie name for Cross Site Request Forgery protection.
  46. */
  47. public string $cookieName = 'csrf_cookie_name';
  48. /**
  49. * --------------------------------------------------------------------------
  50. * CSRF Expires
  51. * --------------------------------------------------------------------------
  52. *
  53. * Expiration time for Cross Site Request Forgery protection cookie.
  54. *
  55. * Defaults to two hours (in seconds).
  56. */
  57. public int $expires = 7200;
  58. /**
  59. * --------------------------------------------------------------------------
  60. * CSRF Regenerate
  61. * --------------------------------------------------------------------------
  62. *
  63. * Regenerate CSRF Token on every submission.
  64. */
  65. public bool $regenerate = true;
  66. /**
  67. * --------------------------------------------------------------------------
  68. * CSRF Redirect
  69. * --------------------------------------------------------------------------
  70. *
  71. * Redirect to previous page with error on failure.
  72. *
  73. * @see https://codeigniter4.github.io/userguide/libraries/security.html#redirection-on-failure
  74. */
  75. public bool $redirect = (ENVIRONMENT === 'production');
  76. }