Security.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. public bool $redirect = false;
  74. /**
  75. * --------------------------------------------------------------------------
  76. * CSRF SameSite
  77. * --------------------------------------------------------------------------
  78. *
  79. * Setting for CSRF SameSite cookie token.
  80. *
  81. * Allowed values are: None - Lax - Strict - ''.
  82. *
  83. * Defaults to `Lax` as recommended in this link:
  84. *
  85. * @see https://portswigger.net/web-security/csrf/samesite-cookies
  86. *
  87. * @deprecated `Config\Cookie` $samesite property is used.
  88. */
  89. public string $samesite = 'Lax';
  90. }