Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
ContentSecurityManager Class Reference

Manage Content Security Policies. More...

Static Public Member Functions

static start (string $nonceGeneratorClass=null, bool $reportOnly=false, ?callable $onGenerate=null)
 Starts the Content Security Policies manager.
 
static getNonce (string $name)
 Returns a new or an existing nonce.
 
static getHash (string $name, string $code, string $algo='sha256')
 Generates a hash and add it to a directive.
 
static hasNonce (string $name)
 
static isStarted ()
 Checks if the manager is started.
 
static addCsp (?bool $reportOnly=null)
 Creates and returns a new ContentSecurity object.
 
static defaultCsp (?bool $reportOnly=null)
 Returns a default ContentSecurity object.
 
static clearCsp ()
 Removes all CSP objects.
 
static defaultUbiquity (?bool $reportOnly=null)
 Creates a new ContentSecurity object for Ubiquity Webtools.
 
static defaultUbiquityDebug (?bool $reportOnly=null, string $livereloadServer='127.0.0.1:35729')
 Creates a new ContentSecurity object for Ubiquity Webtools in debug mode.
 
static addHeadersToResponse (?bool $reportOnly=null)
 Adds all Content security policies to headers.
 
static getNonceGenerator ()
 Returns the NonceGenerator instance.
 
static getCsp ()
 
static isReportOnly ()
 Returns true if reportOnly header is activated.
 
static getHashAlgo ()
 
static setHashAlgo (string $hashAlgo)
 
static setOnGenerate (callable $onGenerate)
 

Static Private Attributes

static NonceGenerator $nonceGenerator
 
static array $csp = []
 
static bool $reportOnly
 
static string $hashAlgo = 'sha256'
 
static $onGenerate
 

Detailed Description

Manage Content Security Policies.

Ubiquity\security\csp$ContentSecurityManager This class is part of Ubiquity

Author
jc
Version
1.0.0

Definition at line 15 of file ContentSecurityManager.php.

Member Function Documentation

◆ addCsp()

static addCsp ( ?bool  $reportOnly = null)
static

Creates and returns a new ContentSecurity object.

Parameters
bool | null$reportOnly
Returns
ContentSecurity

Definition at line 100 of file ContentSecurityManager.php.

◆ addHeadersToResponse()

static addHeadersToResponse ( ?bool  $reportOnly = null)
static

Adds all Content security policies to headers.

Parameters
bool | null$reportOnly

Definition at line 147 of file ContentSecurityManager.php.

◆ clearCsp()

static clearCsp ( )
static

Removes all CSP objects.

Definition at line 117 of file ContentSecurityManager.php.

◆ defaultCsp()

static defaultCsp ( ?bool  $reportOnly = null)
static

Returns a default ContentSecurity object.

Parameters
bool$reportOnly
Returns
ContentSecurity

Definition at line 110 of file ContentSecurityManager.php.

◆ defaultUbiquity()

static defaultUbiquity ( ?bool  $reportOnly = null)
static

Creates a new ContentSecurity object for Ubiquity Webtools.

Parameters
bool | null$reportOnly
Returns
ContentSecurity

Definition at line 127 of file ContentSecurityManager.php.

◆ defaultUbiquityDebug()

static defaultUbiquityDebug ( ?bool  $reportOnly = null,
string  $livereloadServer = '127.0.0.1:35729' 
)
static

Creates a new ContentSecurity object for Ubiquity Webtools in debug mode.

Parameters
bool | null$reportOnly
string$livereloadServer
Returns
ContentSecurity

Definition at line 138 of file ContentSecurityManager.php.

◆ getCsp()

static getCsp ( )
static
Returns
array

Definition at line 167 of file ContentSecurityManager.php.

◆ getHash()

static getHash ( string  $name,
string  $code,
string  $algo = 'sha256' 
)
static

Generates a hash and add it to a directive.

Parameters
string$name
string$code
string$algodefault sha256, possible value sha384,sha512
Returns
string

Definition at line 62 of file ContentSecurityManager.php.

◆ getHashAlgo()

static getHashAlgo ( )
static
Returns
string

Definition at line 184 of file ContentSecurityManager.php.

◆ getNonce()

static getNonce ( string  $name)
static

Returns a new or an existing nonce.

Parameters
string$nameThe nonce to create
Returns
string

Definition at line 49 of file ContentSecurityManager.php.

◆ getNonceGenerator()

static getNonceGenerator ( )
static

Returns the NonceGenerator instance.

Returns
NonceGenerator

Definition at line 159 of file ContentSecurityManager.php.

◆ hasNonce()

static hasNonce ( string  $name)
static
Parameters
string$name
Returns
bool

Definition at line 78 of file ContentSecurityManager.php.

◆ isReportOnly()

static isReportOnly ( )
static

Returns true if reportOnly header is activated.

Returns
bool

Definition at line 176 of file ContentSecurityManager.php.

◆ isStarted()

static isStarted ( )
static

Checks if the manager is started.

Returns
bool

Definition at line 90 of file ContentSecurityManager.php.

◆ setHashAlgo()

static setHashAlgo ( string  $hashAlgo)
static
Parameters
string$hashAlgo

Definition at line 192 of file ContentSecurityManager.php.

◆ setOnGenerate()

static setOnGenerate ( callable  $onGenerate)
static
Parameters
callable$onGenerate

Definition at line 200 of file ContentSecurityManager.php.

◆ start()

static start ( string  $nonceGeneratorClass = null,
bool  $reportOnly = false,
?callable  $onGenerate = null 
)
static

Starts the Content Security Policies manager.

Parameters
string | null$nonceGeneratorClassThe class used for generating nonces.
bool$reportOnly
callable | null$onGenerate

Definition at line 35 of file ContentSecurityManager.php.

Field Documentation

◆ $csp

array $csp = []
staticprivate

Definition at line 19 of file ContentSecurityManager.php.

◆ $hashAlgo

string $hashAlgo = 'sha256'
staticprivate

Definition at line 23 of file ContentSecurityManager.php.

◆ $nonceGenerator

NonceGenerator $nonceGenerator
staticprivate

Definition at line 17 of file ContentSecurityManager.php.

◆ $onGenerate

$onGenerate
staticprivate

Definition at line 25 of file ContentSecurityManager.php.

◆ $reportOnly

bool $reportOnly
staticprivate

Definition at line 21 of file ContentSecurityManager.php.


The documentation for this class was generated from the following file: