TokenStorageInterface.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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\Security\Csrf\TokenStorage;
  11. /**
  12. * Stores CSRF tokens.
  13. *
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. */
  16. interface TokenStorageInterface
  17. {
  18. /**
  19. * Reads a stored CSRF token.
  20. *
  21. * @return string The stored token
  22. *
  23. * @throws \Symfony\Component\Security\Csrf\Exception\TokenNotFoundException If the token ID does not exist
  24. */
  25. public function getToken(string $tokenId);
  26. /**
  27. * Stores a CSRF token.
  28. */
  29. public function setToken(string $tokenId, string $token);
  30. /**
  31. * Removes a CSRF token.
  32. *
  33. * @return string|null Returns the removed token if one existed, NULL
  34. * otherwise
  35. */
  36. public function removeToken(string $tokenId);
  37. /**
  38. * Checks whether a token with the given token ID exists.
  39. *
  40. * @return bool Whether a token exists with the given ID
  41. */
  42. public function hasToken(string $tokenId);
  43. }