| Total Complexity | 5 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | final class QueryParam implements AuthenticationMethodInterface |
||
| 17 | { |
||
| 18 | private const TOKEN_PARAMETER_NAME = 'access-token'; |
||
| 19 | /** |
||
| 20 | * @var string the parameter name for passing the access token |
||
| 21 | */ |
||
| 22 | private string $tokenParameterName = self::TOKEN_PARAMETER_NAME; |
||
| 23 | |||
| 24 | private IdentityRepositoryInterface $identityRepository; |
||
| 25 | |||
| 26 | public function __construct(IdentityRepositoryInterface $identityRepository) |
||
| 29 | } |
||
| 30 | |||
| 31 | public function authenticate(ServerRequestInterface $request): ?IdentityInterface |
||
| 32 | { |
||
| 33 | $accessToken = $request->getQueryParams()[$this->tokenParameterName] ?? null; |
||
| 34 | if (is_string($accessToken)) { |
||
| 35 | return $this->identityRepository->findIdentityByToken($accessToken, get_class($this)); |
||
| 36 | } |
||
| 37 | |||
| 38 | return null; |
||
| 39 | } |
||
| 40 | |||
| 41 | public function challenge(ResponseInterface $response): ResponseInterface |
||
| 44 | } |
||
| 45 | |||
| 46 | public function withTokenParameterName(string $name): self |
||
| 53 |