Skip to content

Commit 3ac6433

Browse files
committed
docs: add docs
1 parent 37ab92e commit 3ac6433

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

user_guide_src/source/changelogs/v4.5.0.rst

+2
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ Others
240240
- ``FileLocatorInterface`` has been added.
241241
- **CodeIgniter:** Added a pseudo-variable ``{memory_usage}`` to show your memory
242242
usage in your view files, which was supported by CodeIgniter 3.
243+
- **CSP:** Added ``ContentSecurityPolicy::clearDirective()`` method to clear
244+
existing CSP directives. See :ref:`csp-clear-directives`.
243245

244246
Message Changes
245247
***************

user_guide_src/source/outgoing/csp.rst

+19-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ call basis, by providing an optional second parameter to the adding method call.
6666
Runtime Configuration
6767
*********************
6868

69-
If your application needs to make changes at run-time, you can access the instance at ``$this->response->getCSP()`` in your controllers. The
69+
If your application needs to make changes at run-time, you can access the instance at ``$this->response->getCSP()`` in your controllers.
70+
71+
The
7072
class holds a number of methods that map pretty clearly to the appropriate header value that you need to set.
7173
Examples are shown below, with different combinations of parameters, though all accept either a directive
7274
name or an array of them:
@@ -76,12 +78,27 @@ name or an array of them:
7678
The first parameter to each of the "add" methods is an appropriate string value,
7779
or an array of them.
7880

81+
Report Only
82+
===========
83+
7984
The ``reportOnly()`` method allows you to specify the default reporting treatment
80-
for subsequent sources, unless over-ridden. For instance, you could specify
85+
for subsequent sources, unless over-ridden.
86+
87+
For instance, you could specify
8188
that youtube.com was allowed, and then provide several allowed but reported sources:
8289

8390
.. literalinclude:: csp/013.php
8491

92+
.. _csp-clear-directives:
93+
94+
Clear Directives
95+
================
96+
97+
If you want to clear existing CSP directives, you can use the ``clearDirective()``
98+
method:
99+
100+
.. literalinclude:: csp/014.php
101+
85102
**************
86103
Inline Content
87104
**************
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
// get the CSP instance
4+
$csp = $this->response->getCSP();
5+
6+
$csp->clearDirective('style-src');

0 commit comments

Comments
 (0)