| 1234567891011121314151617181920212223 |
- <?php
- declare(strict_types=1);
- namespace App\Service\Utils;
- class SecurityUtils
- {
- /**
- * Lève une exception si la méthode a été appelée dans le cadre d'un appel API originaire d'un hôte
- * différent de localhost.
- */
- public static function preventIfNotLocalhost(): void
- {
- if (
- $_SERVER
- && $_SERVER['APP_ENV'] !== 'docker'
- && $_SERVER['SERVER_ADDR'] !== $_SERVER['REMOTE_ADDR']
- ) {
- throw new \RuntimeException('This operation is restricted to localhost');
- }
- }
- }
|