GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Authenticator::checkCredentials()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Bundle\ApiAuthBundle\Security\Jwt;
6
7
use Damax\Bundle\ApiAuthBundle\Extractor\Extractor;
8
use Damax\Bundle\ApiAuthBundle\Jwt\Claims;
9
use Damax\Bundle\ApiAuthBundle\Jwt\TokenParser;
10
use Damax\Bundle\ApiAuthBundle\Security\AbstractAuthenticator;
11
use Damax\Bundle\ApiAuthBundle\Security\ResponseFactory;
12
use Symfony\Component\Security\Core\Exception\AuthenticationException;
13
use Symfony\Component\Security\Core\User\UserInterface;
14
use Symfony\Component\Security\Core\User\UserProviderInterface;
15
16
final class Authenticator extends AbstractAuthenticator
17
{
18
    private $tokenParser;
19
    private $identityClaim;
20
21
    public function __construct(Extractor $extractor, ResponseFactory $response, TokenParser $tokenParser, string $identityClaim = null)
22
    {
23
        parent::__construct($extractor, $response);
24
25
        $this->tokenParser = $tokenParser;
26
        $this->identityClaim = $identityClaim;
27
    }
28
29
    public function checkCredentials($credentials, UserInterface $user): bool
30
    {
31
        return $this->tokenParser->isValid($credentials);
32
    }
33
34
    public function getUser($credentials, UserProviderInterface $userProvider): UserInterface
35
    {
36
        $jwtToken = $this->tokenParser->parse($credentials);
37
38
        if (null === $username = $jwtToken->get($this->identityClaim ?? Claims::SUBJECT)) {
39
            throw new AuthenticationException('Username could not be identified.');
40
        }
41
42
        return $userProvider->loadUserByUsername($username);
43
    }
44
}
45