1 | <?php |
||
13 | class BasicAuthentication |
||
14 | { |
||
15 | use Utils\AuthenticationTrait; |
||
16 | |||
17 | const KEY = 'USERNAME'; |
||
18 | |||
19 | /** |
||
20 | * Returns the username. |
||
21 | * |
||
22 | * @param ServerRequestInterface $request |
||
23 | * |
||
24 | * @return string|null |
||
25 | */ |
||
26 | public static function getUsername(ServerRequestInterface $request) |
||
30 | |||
31 | /** |
||
32 | * Execute the middleware. |
||
33 | * |
||
34 | * @param ServerRequestInterface $request |
||
35 | * @param ResponseInterface $response |
||
36 | * @param callable $next |
||
37 | * |
||
38 | * @return ResponseInterface |
||
39 | */ |
||
40 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
||
55 | |||
56 | /** |
||
57 | * Validate the user and password. |
||
58 | * |
||
59 | * @param string $username |
||
60 | * @param string $password |
||
61 | * |
||
62 | * @return bool |
||
63 | */ |
||
64 | private function checkUserPassword($username, $password) |
||
72 | |||
73 | /** |
||
74 | * Parses the authorization header for a basic authentication. |
||
75 | * |
||
76 | * @param string $header |
||
77 | * |
||
78 | * @return false|array |
||
79 | */ |
||
80 | private static function parseAuthorizationHeader($header) |
||
93 | } |
||
94 |