You are here

public function SecKitEventSubscriber::onKernelResponse in Security Kit 8

Same name and namespace in other branches
  1. 2.x src/EventSubscriber/SecKitEventSubscriber.php \Drupal\seckit\EventSubscriber\SecKitEventSubscriber::onKernelResponse()

Executes actions on the response event.

Parameters

\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event: Filter Response Event object.

File

src/EventSubscriber/SecKitEventSubscriber.php, line 86

Class

SecKitEventSubscriber
Subscribing an event.

Namespace

Drupal\seckit\EventSubscriber

Code

public function onKernelResponse(FilterResponseEvent $event) {
  $this->response = $event
    ->getResponse();

  // Execute necessary functions.
  if ($this->config
    ->get('seckit_xss.csp.checkbox')) {
    $this
      ->seckitCsp();
  }
  if ($this->config
    ->get('seckit_xss.x_xss.select')) {
    $this
      ->seckitXxss($this->config
      ->get('seckit_xss.x_xss.select'));
  }
  if ($this->config
    ->get('seckit_clickjacking.js_css_noscript')) {
    $this
      ->seckitJsCssNoscript();
  }
  if ($this->config
    ->get('seckit_ssl.hsts')) {
    $this
      ->seckitHsts();
  }
  if ($this->config
    ->get('seckit_various.from_origin')) {
    $this
      ->seckitFromOrigin();
  }
  if ($this->config
    ->get('seckit_various.referrer_policy')) {
    $this
      ->seckitReferrerPolicy();
  }
  if ($this->config
    ->get('seckit_ct.expect_ct')) {
    $this
      ->seckitExpectCt();
  }
  if ($this->config
    ->get('seckit_fp.feature_policy')) {
    $this
      ->seckitFeaturePolicy();
  }

  // Always call this (regardless of the setting) since if it's disabled it
  // may be necessary to actively disable the core's clickjacking defense.
  $this
    ->seckitXframe($this->config
    ->get('seckit_clickjacking.x_frame'), $event);
}