• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemsdk / docker-symfony-api / #74

pending completion
#74

push

DKravtsov
Php 8.2, symfony 6.2, updated RabbitMQ, updated composer dependencies, refactoring.

51 of 51 new or added lines in 44 files covered. (100.0%)

1479 of 2668 relevant lines covered (55.43%)

23.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

10.0
/src/ApiKey/Application/Security/Provider/ApiKeyUserProvider.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace App\ApiKey\Application\Security\Provider;
6

7
use App\ApiKey\Application\Security\ApiKeyUser;
8
use App\ApiKey\Application\Security\Provider\Interfaces\ApiKeyUserProviderInterface;
9
use App\ApiKey\Domain\Entity\ApiKey;
10
use App\ApiKey\Domain\Repository\Interfaces\ApiKeyRepositoryInterface;
11
use App\Role\Application\Security\RolesService;
12
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
13
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
14
use Symfony\Component\Security\Core\User\UserInterface;
15
use Symfony\Component\Security\Core\User\UserProviderInterface;
16

17
/**
18
 * Class ApiKeyUserProvider
19
 *
20
 * @package App\ApiKey
21
 */
22
class ApiKeyUserProvider implements ApiKeyUserProviderInterface, UserProviderInterface
23
{
24
    /**
25
     * @param \App\ApiKey\Infrastructure\Repository\ApiKeyRepository $apiKeyRepository
26
     */
27
    public function __construct(
28
        private readonly ApiKeyRepositoryInterface $apiKeyRepository,
29
        private readonly RolesService $rolesService,
30
    ) {
31
    }
145✔
32

33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function supportsClass(string $class): bool
37
    {
38
        return $class === ApiKeyUser::class;
×
39
    }
40

41
    public function loadUserByIdentifier(string $identifier): ApiKeyUser
42
    {
43
        $apiKey = $this->getApiKeyForToken($identifier);
×
44

45
        if ($apiKey === null) {
×
46
            throw new UserNotFoundException('API key is not valid');
×
47
        }
48

49
        return new ApiKeyUser($apiKey, $this->rolesService->getInheritedRoles($apiKey->getRoles()));
×
50
    }
51

52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function refreshUser(UserInterface $user): UserInterface
56
    {
57
        throw new UnsupportedUserException('API key cannot refresh user');
×
58
    }
59

60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function getApiKeyForToken(string $token): ?ApiKey
64
    {
65
        return $this->apiKeyRepository->findOneBy([
×
66
            'token' => $token,
×
67
        ]);
×
68
    }
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc