|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * This file is part of the CodeIgniter 4 framework. |
| 5 | + * |
| 6 | + * (c) CodeIgniter Foundation <admin@codeigniter.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace CodeIgniter\Security; |
| 13 | + |
| 14 | +use CodeIgniter\HTTP\RequestInterface; |
| 15 | +use CodeIgniter\Security\Exceptions\SecurityException; |
| 16 | + |
| 17 | +/** |
| 18 | + * Expected behavior of a Security. |
| 19 | + */ |
| 20 | +interface SecurityInterface |
| 21 | +{ |
| 22 | + /** |
| 23 | + * CSRF Verify |
| 24 | + * |
| 25 | + * @param RequestInterface $request |
| 26 | + * |
| 27 | + * @return $this|false |
| 28 | + * |
| 29 | + * @throws SecurityException |
| 30 | + */ |
| 31 | + public function verify(RequestInterface $request); |
| 32 | + |
| 33 | + /** |
| 34 | + * Returns the CSRF Hash. |
| 35 | + * |
| 36 | + * @return string|null |
| 37 | + */ |
| 38 | + public function getHash(): ?string; |
| 39 | + |
| 40 | + /** |
| 41 | + * Returns the CSRF Token Name. |
| 42 | + * |
| 43 | + * @return string |
| 44 | + */ |
| 45 | + public function getTokenName(): string; |
| 46 | + |
| 47 | + /** |
| 48 | + * Returns the CSRF Header Name. |
| 49 | + * |
| 50 | + * @return string |
| 51 | + */ |
| 52 | + public function getHeaderName(): string; |
| 53 | + |
| 54 | + /** |
| 55 | + * Returns the CSRF Cookie Name. |
| 56 | + * |
| 57 | + * @return string |
| 58 | + */ |
| 59 | + public function getCookieName(): string; |
| 60 | + |
| 61 | + /** |
| 62 | + * Check if CSRF cookie is expired. |
| 63 | + * |
| 64 | + * @return boolean |
| 65 | + */ |
| 66 | + public function isExpired(): bool; |
| 67 | + |
| 68 | + /** |
| 69 | + * Check if request should be redirect on failure. |
| 70 | + * |
| 71 | + * @return boolean |
| 72 | + */ |
| 73 | + public function shouldRedirect(): bool; |
| 74 | + |
| 75 | + /** |
| 76 | + * Sanitize Filename |
| 77 | + * |
| 78 | + * Tries to sanitize filenames in order to prevent directory traversal attempts |
| 79 | + * and other security threats, which is particularly useful for files that |
| 80 | + * were supplied via user input. |
| 81 | + * |
| 82 | + * If it is acceptable for the user input to include relative paths, |
| 83 | + * e.g. file/in/some/approved/folder.txt, you can set the second optional |
| 84 | + * parameter, $relative_path to TRUE. |
| 85 | + * |
| 86 | + * @param string $str Input file name |
| 87 | + * @param boolean $relativePath Whether to preserve paths |
| 88 | + * |
| 89 | + * @return string |
| 90 | + */ |
| 91 | + public function sanitizeFilename(string $str, bool $relativePath = false): string; |
| 92 | +} |
0 commit comments