-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3961 from mostafakhudair/refactor-security-class
Refactor Security Class
- Loading branch information
Showing
14 changed files
with
490 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
namespace Config; | ||
|
||
use CodeIgniter\Config\BaseConfig; | ||
|
||
class Security extends BaseConfig | ||
{ | ||
/** | ||
* -------------------------------------------------------------------------- | ||
* CSRF Token Name | ||
* -------------------------------------------------------------------------- | ||
* | ||
* Token name for Cross Site Request Forgery protection cookie. | ||
* | ||
* @var string | ||
*/ | ||
public $tokenName = 'csrf_test_name'; | ||
|
||
/** | ||
* -------------------------------------------------------------------------- | ||
* CSRF Header Name | ||
* -------------------------------------------------------------------------- | ||
* | ||
* Token name for Cross Site Request Forgery protection cookie. | ||
* | ||
* @var string | ||
*/ | ||
public $headerName = 'X-CSRF-TOKEN'; | ||
|
||
/** | ||
* -------------------------------------------------------------------------- | ||
* CSRF Cookie Name | ||
* -------------------------------------------------------------------------- | ||
* | ||
* Cookie name for Cross Site Request Forgery protection cookie. | ||
* | ||
* @var string | ||
*/ | ||
public $cookieName = 'csrf_cookie_name'; | ||
|
||
/** | ||
* -------------------------------------------------------------------------- | ||
* CSRF Expires | ||
* -------------------------------------------------------------------------- | ||
* | ||
* Expiration time for Cross Site Request Forgery protection cookie. | ||
* | ||
* Defaults to two hours (in seconds). | ||
* | ||
* @var integer | ||
*/ | ||
public $expires = 7200; | ||
|
||
/** | ||
* -------------------------------------------------------------------------- | ||
* CSRF Regenerate | ||
* -------------------------------------------------------------------------- | ||
* | ||
* Regenerate CSRF Token on every request. | ||
* | ||
* @var boolean | ||
*/ | ||
public $regenerate = true; | ||
|
||
/** | ||
* -------------------------------------------------------------------------- | ||
* CSRF Redirect | ||
* -------------------------------------------------------------------------- | ||
* | ||
* Redirect to previous page with error on failure. | ||
* | ||
* @var boolean | ||
*/ | ||
public $redirect = true; | ||
|
||
/** | ||
* -------------------------------------------------------------------------- | ||
* CSRF SameSite | ||
* -------------------------------------------------------------------------- | ||
* | ||
* Setting for CSRF SameSite cookie token. | ||
* | ||
* Allowed values are: None - Lax - Strict - ''. | ||
* | ||
* Defaults to `Lax` as recommended in this link: | ||
* @see https://portswigger.net/web-security/csrf/samesite-cookies | ||
* | ||
* @var string | ||
*/ | ||
public $samesite = 'Lax'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the CodeIgniter 4 framework. | ||
* | ||
* (c) CodeIgniter Foundation <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
// Security language settings | ||
return [ | ||
'disallowedAction' => 'The action you requested is not allowed.', | ||
'invalidSameSite' => 'The SameSite value must be None, Lax, Strict, or a blank string. Given: {0}', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.