Added X-XSS-Protection header support

This commit is contained in:
alistair3149 2019-12-31 02:36:17 -05:00
parent 24b74796f4
commit 286c2d5acc
No known key found for this signature in database
GPG key ID: 94D081060FD3DD9C
3 changed files with 25 additions and 0 deletions

View file

@ -80,6 +80,12 @@ WIP section, refer to below:
"descriptionmsg": "citizen-config-enabledenyxframeoptions",
"public": true
},
"EnableXXSSProtection": {
"value": false,
"description": "Enable or disable the X-XSS-Protection header",
"descriptionmsg": "citizen-config-enablexxssprotection",
"public": true
},
"EnableFeaturePolicy": {
"value": false,
"description": "Enable or disable Feature Policy",

View file

@ -44,6 +44,9 @@ class SkinCitizen extends SkinTemplate {
// Deny X-Frame-Options
$this->addXFrameOptions();
// X-XSS-Protection
$this->addXXSSProtection();
// Feature policy
$this->addFeaturePolicy();
@ -165,6 +168,16 @@ class SkinCitizen extends SkinTemplate {
}
}
/**
* Adds the X-XSS-Protection header if set in 'CitizenEnableXXSSProtection'
*/
private function addXXSSProtection() {
if ( $this->getConfigValue( 'CitizenEnableXXSSProtection' ) === true ) {
$this->out->getRequest()->response()->header( 'X-XSS-Protection: 1; mode=block' );
}
}
/**
* Adds the Feature policy header to the response if enabled in 'CitizenFeaturePolicyDirective'
*/

View file

@ -81,6 +81,12 @@
"descriptionmsg": "citizen-config-enabledenyxframeoptions",
"public": true
},
"EnableXXSSProtection": {
"value": false,
"description": "Enable or disable the X-XSS-Protection header",
"descriptionmsg": "citizen-config-enablexxssprotection",
"public": true
},
"EnableFeaturePolicy": {
"value": false,
"description": "Enable or disable Feature Policy",