com\setasign\SetaFramework\Helper

CspHelper Helper class for content security policies

File: /SetaFramework/src/Helper/CspHelper.php

Class hierarchy

Summary

Properties

$enabled

public CspHelper::$enabled = false

$hashes

protected CspHelper::$hashes = array()

$nonceValues

protected CspHelper::$nonceValues = array()

Methods

enforceNonce()

public CspHelper::enforceNonce (
string|'script-src'|'style-src' $directive,
string $value
): void
Parameters
$directive: string|'script-src'|'style-src'
 
$value: string
 

getAllNonceValues()

public CspHelper::getAllNonceValues (
void
): array

getHashes()

public CspHelper::getHashes (
void
): array

getNonce()

public CspHelper::getNonce (
string|'script-src'|'style-src' $directive
): string

Returns a nonce value for the directive. If no nonce value was generated yet, it will be generated.

Parameters
$directive: string|'script-src'|'style-src'
 

saveHash()

public CspHelper::saveHash (
string $directive,
string $content,
string $hashAlgorithm = 'sha384'
): string
Parameters
$directive: string
 
$content: string
 
$hashAlgorithm: string