Lines
100.00%
7 / 7
Methods
100.00%
1 / 1
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| getAuthenticatedUser | 100.00% | 7 / 7 | 100.00% | 1 / 1 | 3 | ||
| 11 | abstract class AuthenticationService | |
| 12 | { | |
| 13 | public static function getAuthenticatedUser(RequestInterface $request): AuthenticatedUser | null | |
| 14 | { | |
| 15 | $authHeader = $request->getHeaderLine('Authorization'); | |
| 16 | if (empty($authHeader)) { | |
| 17 | return null; | |
| 18 | } | |
| 19 | if (!preg_match('/Bearer\s(\S+)/', $authHeader, $matches)) { | |
| 20 | throw new InvalidAuthTokenException('authKeyMismatch', 'Invalid JWT payload.'); | |
| 21 | } | |
| 22 | $token = $matches[1]; | |
| 23 | return AuthenticatedUser::fromJwtPayload($token); | |
| 24 | } | |
| 25 | } |