| Conditions | 5 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function executeBefore(Request $request, array $hookData) |
||
| 29 | { |
||
| 30 | $authUser = $request->getHeader('PHP_AUTH_USER', false); |
||
| 31 | $authPass = $request->getHeader('PHP_AUTH_PW', false); |
||
| 32 | if (is_null($authUser) || is_null($authPass)) { |
||
| 33 | throw new HttpException( |
||
| 34 | 'missing authentication information', |
||
| 35 | 401, |
||
| 36 | ['WWW-Authenticate' => sprintf('Basic realm="%s"', $this->realm)] |
||
| 37 | ); |
||
| 38 | } |
||
| 39 | |||
| 40 | if (array_key_exists($authUser, $this->userPass)) { |
||
| 41 | if (0 === \Sodium\compare($authPass, $this->userPass[$authUser])) { |
||
| 42 | return $authUser; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | throw new HttpException( |
||
| 47 | 'invalid authentication information', |
||
| 48 | 401, |
||
| 49 | ['WWW-Authenticate' => sprintf('Basic realm="%s"', $this->realm)] |
||
| 50 | ); |
||
| 51 | } |
||
| 52 | } |
||
| 53 |