-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathUserProvider.php
More file actions
38 lines (33 loc) · 1.02 KB
/
UserProvider.php
File metadata and controls
38 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace Uecode\Bundle\ApiKeyBundle\Security\Authentication\Provider;
use FOS\UserBundle\Security\UserProvider as FOSUserProvider;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\UserInterface as SecurityUserInterface;
/**
* @author Aaron Scherer <aequasi@gmail.com>
*/
class UserProvider extends FOSUserProvider implements ApiKeyUserProviderInterface
{
/**
* @var bool Stateless Authentication?
*/
private $stateless = false;
public function loadUserByApiKey($apiKey)
{
$this->stateless = true;
return $this->userManager->findUserBy(array('apiKey' => $apiKey));
}
/**
* @param SecurityUserInterface $user
*
* @return SecurityUserInterface
* @throws UnsupportedUserException
*/
public function refreshUser(SecurityUserInterface $user)
{
if ($this->stateless) {
throw new UnsupportedUserException();
}
return parent::refreshUser($user);
}
}