mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
Pull out security header check
This commit is contained in:
parent
2b63386f9f
commit
f176329d6c
|
|
@ -114,6 +114,26 @@ class Header extends HeaderAbstract
|
|||
return array_key_exists($key, $this->header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is security header.
|
||||
*
|
||||
* @param string $key Header key
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
private function isSecurityHeader(string $key) : bool
|
||||
{
|
||||
return $key === 'content-security-policy' ||
|
||||
$key === 'x-xss-protection' ||
|
||||
$key === 'x-content-type-options' ||
|
||||
$key === 'x-frame-options';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -128,10 +148,7 @@ class Header extends HeaderAbstract
|
|||
if (!$overwrite && isset($this->header[$key])) {
|
||||
return false;
|
||||
} elseif ($overwrite && isset($this->header[$key])) {
|
||||
if($key === 'content-security-policy' ||
|
||||
$key === 'x-xss-protection' ||
|
||||
$key === 'x-content-type-options' ||
|
||||
$key === 'x-frame-options') {
|
||||
if ($this->isSecurityHeader($key)) {
|
||||
throw new \Exception('Cannot change security headers.');
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +219,8 @@ class Header extends HeaderAbstract
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getStatusCode() : int {
|
||||
public static function getStatusCode() : int
|
||||
{
|
||||
return http_response_code();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user