X-Git-Url: https://git-public.kairo.at/?p=authserver.git;a=blobdiff_plain;f=authutils.php-class;h=9cd000c492d6c1e0ac8872fea75a124e410cb8a3;hp=dc06a7f7547ab17cabfce789fe2c1624de47b477;hb=b0e48c35c57284bf91bb8b3dc2da4c8a3206617c;hpb=88191064f51f758e3dcd11cc7cd9612770316895 diff --git a/authutils.php-class b/authutils.php-class index dc06a7f..9cd000c 100755 --- a/authutils.php-class +++ b/authutils.php-class @@ -107,6 +107,26 @@ class AuthUtils { return $errors; } + function sendSecurityHeaders() { + // Send various headers that we want to have for security resons, mostly as recommended by https://observatory.mozilla.org/ + + // CSP - see https://wiki.mozilla.org/Security/Guidelines/Web_Security#Content_Security_Policy + // Disable unsafe inline/eval, only allow loading of resources (images, fonts, scripts, etc.) from ourselves; also disable framing. + header('Content-Security-Policy: default-src \'none\';img-src \'self\'; script-src \'self\'; style-src \'self\'; frame-ancestors \'none\''); + + // X-Content-Type-Options - see https://wiki.mozilla.org/Security/Guidelines/Web_Security#X-Content-Type-Options + // Prevent browsers from incorrectly detecting non-scripts as scripts + header('X-Content-Type-Options: nosniff'); + + // X-Frame-Options (for older browsers) - see https://wiki.mozilla.org/Security/Guidelines/Web_Security#X-Frame-Options + // Block site from being framed + header('X-Frame-Options: DENY'); + + // X-XSS-Protection (for older browsers) - see https://wiki.mozilla.org/Security/Guidelines/Web_Security#X-XSS-Protection + // Block pages from loading when they detect reflected XSS attacks + header('X-XSS-Protection: 1; mode=block'); + } + function initSession() { $session = null; if (strlen(@$_COOKIE['sessionkey'])) {