TokenStorageInterface.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. * @param string $tokenId The token ID
  22. *
  23. * @return string The stored token
  24. *
  25. * @throws \Symfony\Component\Security\Csrf\Exception\TokenNotFoundException If the token ID does not exist
  26. */
  27. public function getToken($tokenId);
  28. /**
  29. * Stores a CSRF token.
  30. *
  31. * @param string $tokenId The token ID
  32. * @param string $token The CSRF token
  33. */
  34. public function setToken($tokenId, $token);
  35. /**
  36. * Removes a CSRF token.
  37. *
  38. * @param string $tokenId The token ID
  39. *
  40. * @return string|null Returns the removed token if one existed, NULL
  41. * otherwise
  42. */
  43. public function removeToken($tokenId);
  44. /**
  45. * Checks whether a token with the given token ID exists.
  46. *
  47. * @param string $tokenId The token ID
  48. *
  49. * @return bool Whether a token exists with the given ID
  50. */
  51. public function hasToken($tokenId);
  52. }