You are here

class SiteLog in Content-Security-Policy 8

Csp Reporting Handler to use Drupal log.

Plugin annotation


@CspReportingHandler(
  id = "sitelog",
  label = @Translation("Site Log"),
  description = @Translation("Reports will be added to the site log."),
)

Hierarchy

Expanded class hierarchy of SiteLog

File

src/Plugin/CspReportingHandler/SiteLog.php, line 18

Namespace

Drupal\csp\Plugin\CspReportingHandler
View source
class SiteLog extends ReportingHandlerBase {

  /**
   * {@inheritdoc}
   */
  public function alterPolicy(Csp $policy) {
    $reportUri = Url::fromRoute('csp.reporturi', [
      'type' => $this->configuration['type'] == 'enforce' ? 'enforce' : 'reportOnly',
    ], [
      'absolute' => TRUE,
    ]);
    $policy
      ->setDirective('report-uri', $reportUri
      ->toString());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ReportingHandlerBase::$configuration protected property The Plugin Configuration.
ReportingHandlerBase::$pluginDefinition protected property The Plugin Definition.
ReportingHandlerBase::$pluginId protected property The Plugin ID.
ReportingHandlerBase::getForm public function Get the form fields for configuring this reporting handler. Overrides ReportingHandlerInterface::getForm 2
ReportingHandlerBase::validateForm public function Validate the form fields of this report handler. Overrides ReportingHandlerInterface::validateForm 2
ReportingHandlerBase::__construct public function Reporting Handler plugin constructor.
SiteLog::alterPolicy public function Alter the provided policy according to the plugin settings. Overrides ReportingHandlerBase::alterPolicy