Skip to content

Commit 0f80171

Browse files
committed
Remove deprecated items in Security
1 parent 52011ea commit 0f80171

File tree

4 files changed

+13
-148
lines changed

4 files changed

+13
-148
lines changed

system/Security/Security.php

Lines changed: 0 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
use SensitiveParameter;
3030

3131
/**
32-
* Class Security
33-
*
3432
* Provides methods that help protect your site against
3533
* Cross-Site Request Forgery attacks.
3634
*
@@ -42,26 +40,6 @@ class Security implements SecurityInterface
4240
public const CSRF_PROTECTION_SESSION = 'session';
4341
protected const CSRF_HASH_BYTES = 16;
4442

45-
/**
46-
* CSRF Protection Method
47-
*
48-
* Protection Method for Cross Site Request Forgery protection.
49-
*
50-
* @var string 'cookie' or 'session'
51-
*
52-
* @deprecated 4.4.0 Use $this->config->csrfProtection.
53-
*/
54-
protected $csrfProtection = self::CSRF_PROTECTION_COOKIE;
55-
56-
/**
57-
* CSRF Token Randomization
58-
*
59-
* @var bool
60-
*
61-
* @deprecated 4.4.0 Use $this->config->tokenRandomize.
62-
*/
63-
protected $tokenRandomize = false;
64-
6543
/**
6644
* CSRF Hash (without randomization)
6745
*
@@ -71,28 +49,6 @@ class Security implements SecurityInterface
7149
*/
7250
protected $hash;
7351

74-
/**
75-
* CSRF Token Name
76-
*
77-
* Token name for Cross Site Request Forgery protection.
78-
*
79-
* @var string
80-
*
81-
* @deprecated 4.4.0 Use $this->config->tokenName.
82-
*/
83-
protected $tokenName = 'csrf_token_name';
84-
85-
/**
86-
* CSRF Header Name
87-
*
88-
* Header name for Cross Site Request Forgery protection.
89-
*
90-
* @var string
91-
*
92-
* @deprecated 4.4.0 Use $this->config->headerName.
93-
*/
94-
protected $headerName = 'X-CSRF-TOKEN';
95-
9652
/**
9753
* The CSRF Cookie instance.
9854
*
@@ -109,58 +65,6 @@ class Security implements SecurityInterface
10965
*/
11066
protected $cookieName = 'csrf_cookie_name';
11167

112-
/**
113-
* CSRF Expires
114-
*
115-
* Expiration time for Cross Site Request Forgery protection cookie.
116-
*
117-
* Defaults to two hours (in seconds).
118-
*
119-
* @var int
120-
*
121-
* @deprecated 4.4.0 Use $this->config->expires.
122-
*/
123-
protected $expires = 7200;
124-
125-
/**
126-
* CSRF Regenerate
127-
*
128-
* Regenerate CSRF Token on every request.
129-
*
130-
* @var bool
131-
*
132-
* @deprecated 4.4.0 Use $this->config->regenerate.
133-
*/
134-
protected $regenerate = true;
135-
136-
/**
137-
* CSRF Redirect
138-
*
139-
* Redirect to previous page with error on failure.
140-
*
141-
* @var bool
142-
*
143-
* @deprecated 4.4.0 Use $this->config->redirect.
144-
*/
145-
protected $redirect = false;
146-
147-
/**
148-
* CSRF SameSite
149-
*
150-
* Setting for CSRF SameSite cookie token.
151-
*
152-
* Allowed values are: None - Lax - Strict - ''.
153-
*
154-
* Defaults to `Lax` as recommended in this link:
155-
*
156-
* @see https://portswigger.net/web-security/csrf/samesite-cookies
157-
*
158-
* @var string
159-
*
160-
* @deprecated `Config\Cookie` $samesite property is used.
161-
*/
162-
protected $samesite = Cookie::SAMESITE_LAX;
163-
16468
private readonly IncomingRequest $request;
16569

16670
/**
@@ -454,29 +358,6 @@ public function shouldRedirect(): bool
454358
return $this->config->redirect;
455359
}
456360

457-
/**
458-
* Sanitize Filename
459-
*
460-
* Tries to sanitize filenames in order to prevent directory traversal attempts
461-
* and other security threats, which is particularly useful for files that
462-
* were supplied via user input.
463-
*
464-
* If it is acceptable for the user input to include relative paths,
465-
* e.g. file/in/some/approved/folder.txt, you can set the second optional
466-
* parameter, $relativePath to TRUE.
467-
*
468-
* @deprecated 4.6.2 Use `sanitize_filename()` instead
469-
*
470-
* @param string $str Input file name
471-
* @param bool $relativePath Whether to preserve paths
472-
*/
473-
public function sanitizeFilename(string $str, bool $relativePath = false): string
474-
{
475-
helper('security');
476-
477-
return sanitize_filename($str, $relativePath);
478-
}
479-
480361
/**
481362
* Restore hash from Session or Cookie
482363
*/

system/Security/SecurityInterface.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
interface SecurityInterface
2323
{
2424
/**
25-
* CSRF Verify
25+
* Verify CSRF token sent with the request.
2626
*
27-
* @return $this|false
27+
* @return $this
2828
*
2929
* @throws SecurityException
3030
*/
@@ -54,22 +54,4 @@ public function getCookieName(): string;
5454
* Check if request should be redirect on failure.
5555
*/
5656
public function shouldRedirect(): bool;
57-
58-
/**
59-
* Sanitize Filename
60-
*
61-
* Tries to sanitize filenames in order to prevent directory traversal attempts
62-
* and other security threats, which is particularly useful for files that
63-
* were supplied via user input.
64-
*
65-
* If it is acceptable for the user input to include relative paths,
66-
* e.g. file/in/some/approved/folder.txt, you can set the second optional
67-
* parameter, $relativePath to TRUE.
68-
*
69-
* @deprecated 4.6.2 Use `sanitize_filename()` instead
70-
*
71-
* @param string $str Input file name
72-
* @param bool $relativePath Whether to preserve paths
73-
*/
74-
public function sanitizeFilename(string $str, bool $relativePath = false): string;
7557
}

tests/system/Security/SecurityTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,6 @@ public function testCsrfVerifyPutBodyReturnsSelfOnMatch(): void
240240
$this->assertSame('foo=bar', $request->getBody());
241241
}
242242

243-
public function testSanitizeFilename(): void
244-
{
245-
$security = $this->createMockSecurity();
246-
247-
$filename = './<!--foo-->';
248-
249-
$this->assertSame('foo', $security->sanitizeFilename($filename));
250-
}
251-
252243
public function testRegenerateWithFalseSecurityRegenerateProperty(): void
253244
{
254245
service('superglobals')

user_guide_src/source/changelogs/v4.8.0.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ Removed Deprecated Items
4343
- ``CodeIgniter\Debug\Exceptions::cleanPath()``
4444
- ``CodeIgniter\Debug\Exceptions::describeMemory()``
4545
- ``CodeIgniter\Debug\Exceptions::highlightFile()``
46+
- **Security:** Removed the following properties and methods deprecated:
47+
- ``CodeIgniter\Security\SecurityInterface::sanitizeFilename()`` (deprecated since v4.6.2)
48+
- ``CodeIgniter\Security\Security::sanitizeFilename()`` (deprecated since v4.6.2)
49+
- ``CodeIgniter\Security\Security::$csrfProtection`` (deprecated since v4.4.0)
50+
- ``CodeIgniter\Security\Security::$tokenRandomize`` (deprecated since v4.4.0)
51+
- ``CodeIgniter\Security\Security::$tokenName`` (deprecated since v4.4.0)
52+
- ``CodeIgniter\Security\Security::$headerName`` (deprecated since v4.4.0)
53+
- ``CodeIgniter\Security\Security::$expires`` (deprecated since v4.4.0)
54+
- ``CodeIgniter\Security\Security::$regenerate`` (deprecated since v4.4.0)
55+
- ``CodeIgniter\Security\Security::$redirect`` (deprecated since v4.4.0)
56+
- ``CodeIgniter\Security\Security::$sameSite`` (deprecated since v4.4.0)
4657

4758
************
4859
Enhancements

0 commit comments

Comments
 (0)