UserProviderInterface.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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\Core\User;
  11. use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
  12. use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
  13. /**
  14. * Represents a class that loads UserInterface objects from some source for the authentication system.
  15. *
  16. * In a typical authentication configuration, a username (i.e. some unique
  17. * user identifier) credential enters the system (via form login, or any
  18. * method). The user provider that is configured with that authentication
  19. * method is asked to load the UserInterface object for the given username
  20. * (via loadUserByUsername) so that the rest of the process can continue.
  21. *
  22. * Internally, a user provider can load users from any source (databases,
  23. * configuration, web service). This is totally independent of how the authentication
  24. * information is submitted or what the UserInterface object looks like.
  25. *
  26. * @see UserInterface
  27. *
  28. * @author Fabien Potencier <fabien@symfony.com>
  29. */
  30. interface UserProviderInterface
  31. {
  32. /**
  33. * Loads the user for the given username.
  34. *
  35. * This method must throw UsernameNotFoundException if the user is not
  36. * found.
  37. *
  38. * @param string $username The username
  39. *
  40. * @return UserInterface
  41. *
  42. * @throws UsernameNotFoundException if the user is not found
  43. */
  44. public function loadUserByUsername($username);
  45. /**
  46. * Refreshes the user.
  47. *
  48. * It is up to the implementation to decide if the user data should be
  49. * totally reloaded (e.g. from the database), or if the UserInterface
  50. * object can just be merged into some internal array of users / identity
  51. * map.
  52. *
  53. * @return UserInterface
  54. *
  55. * @throws UnsupportedUserException if the user is not supported
  56. */
  57. public function refreshUser(UserInterface $user);
  58. /**
  59. * Whether this provider supports the given user class.
  60. *
  61. * @param string $class
  62. *
  63. * @return bool
  64. */
  65. public function supportsClass($class);
  66. }