Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
39 | public function checkOrigin(string $headers): bool |
||
40 | { |
||
41 | preg_match('/Origin\:\s(.*?)\s/', $headers, $matches); |
||
42 | if (empty($matches[1])) { |
||
43 | $this->sendAndClose('No Origin header found.'); |
||
44 | return false; |
||
45 | } |
||
46 | |||
47 | $originHost = $matches[1]; |
||
48 | $allowedOrigins = $this->config->getOrigins(); |
||
49 | if (in_array($originHost, $allowedOrigins, true) === false) { |
||
50 | $this->sendAndClose('Host ' . $originHost . ' is not allowed to pass access control as origin.'); |
||
51 | return false; |
||
52 | } |
||
53 | |||
54 | return true; |
||
55 | } |
||
67 | } |