1: <?php
2:
3: namespace Mapbender\DrupalIntegrationBundle\Security\Authentication\Provider;
4:
5: use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface;
6: use Symfony\Component\Security\Core\User\UserProviderInterface;
7: use Symfony\Component\Security\Core\Exception\AuthenticationException;
8: use Symfony\Component\Security\Core\Exception\NonceExpiredException;
9: use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
10: use Mapbender\DrupalIntegrationBundle\Authentication\Token\DrupalUserToken;
11:
12:
13: class DrupalProvider implements AuthenticationProviderInterface
14: {
15: private $userProvider;
16: private $cacheDir;
17:
18: public function __construct(UserProviderInterface $userProvider)
19: {
20: $this->userProvider = $userProvider;
21: }
22:
23: public function authenticate(TokenInterface $token)
24: {
25: $user = $this->userProvider->loadUserByUsername($token->getUsername());
26:
27: $authenticatedToken = new DrupalUserToken($user->getRoles());
28: $authenticatedToken->setUser($user);
29:
30: return $authenticatedToken;
31: }
32:
33: public function supports(TokenInterface $token)
34: {
35: return $token instanceof DrupalUserToken;
36: }
37: }
38: