IsSignatureValid.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel\Attribute;
  11. /**
  12. * Validates the request signature for specific HTTP methods.
  13. *
  14. * This class determines whether a request's signature should be validated
  15. * based on the configured HTTP methods. If the request method matches one
  16. * of the specified methods (or if no methods are specified), the signature
  17. * is checked.
  18. *
  19. * If the signature is invalid, a {@see \Symfony\Component\HttpFoundation\Exception\SignedUriException}
  20. * is thrown during validation.
  21. *
  22. * @author Santiago San Martin <sanmartindev@gmail.com>
  23. */
  24. #[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::TARGET_FUNCTION)]
  25. final class IsSignatureValid
  26. {
  27. /** @var string[] */
  28. public readonly array $methods;
  29. /**
  30. * @param string[]|string $methods HTTP methods that require signature validation. An empty array means that no method filtering is done
  31. */
  32. public function __construct(
  33. array|string $methods = [],
  34. ) {
  35. $this->methods = (array) $methods;
  36. }
  37. }