VuFind API Documentation

CspHeaderGenerator
in package
implements LoggerAwareInterface Uses LoggerAwareTrait

VuFind class for generating Content Security Policy http headers.

Also generates related headers like NEL (network error logging) and reporting headers like Report-To.

Tags
category

VuFind

author

Josef Moravec moravec@mzk.cz

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

SuppressWarnings

(PHPMD.NumberOfChildren)

Interfaces, Classes, Traits and Enums

LoggerAwareInterface

Table of Contents

$config  : Config
Configuration for generator from contensecuritypolicy.ini
$nonce  : string
Generated nonce used for one request
$scriptDirectives  : array<string|int, string>
List of directives that can work with nonce
__construct()  : mixed
CspHeaderGenerator constructor.
getCspHeader()  : ContentSecurityPolicy
Create CSP header base on given configuration
getHeader()  : ContentSecurityPolicy
Create CSP header base on given configuration
getHeaders()  : array<string|int, mixed>
Create all relevant CSP-related headers based on given configuration
getNetworkErrorLoggingHeader()  : GenericHeader|null
Create NEL (Network Error Logging) header based on given configuration
getReportToHeader()  : GenericHeader|null
Create Report-To header based on given configuration
createHeaderObject()  : ContentSecurityPolicy
Create header object
debug()  : void
Log a debug message.
log()  : void
Send a message to the logger.
logError()  : void
Log an error message.
logWarning()  : void
Log a warning message.

Properties

$config

Configuration for generator from contensecuritypolicy.ini

protected Config $config

$scriptDirectives

List of directives that can work with nonce

protected array<string|int, string> $scriptDirectives = ['script-src', 'script-src-elem']

Methods

__construct()

CspHeaderGenerator constructor.

public __construct(Config $config, NonceGenerator $nonceGenerator) : mixed
Parameters
$config : Config

Configuration

$nonceGenerator : NonceGenerator

Nonce generator

Return values
mixed

getCspHeader()

Create CSP header base on given configuration

public getCspHeader() : ContentSecurityPolicy
Return values
ContentSecurityPolicy

getHeader()

Create CSP header base on given configuration

public getHeader() : ContentSecurityPolicy
Tags
deprecated

Use getCspHeader instead

Return values
ContentSecurityPolicy

getHeaders()

Create all relevant CSP-related headers based on given configuration

public getHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>

getNetworkErrorLoggingHeader()

Create NEL (Network Error Logging) header based on given configuration

public getNetworkErrorLoggingHeader() : GenericHeader|null
Return values
GenericHeader|null

getReportToHeader()

Create Report-To header based on given configuration

public getReportToHeader() : GenericHeader|null
Return values
GenericHeader|null

createHeaderObject()

Create header object

protected createHeaderObject() : ContentSecurityPolicy
Return values
ContentSecurityPolicy

debug()

Log a debug message.

protected debug(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

log()

Send a message to the logger.

protected log(string $level, string $message[, array<string|int, mixed> $context = [] ][, bool $prependClass = false ]) : void
Parameters
$level : string

Log level

$message : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = false

Prepend class name to message?

Return values
void

logError()

Log an error message.

protected logError(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

logWarning()

Log a warning message.

protected logWarning(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

Search results