You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/outgoing/csp.rst
+14-3Lines changed: 14 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ the response's ``Content-Security-Policy`` header and offers various configurati
21
21
options.
22
22
23
23
This sounds complex, and on some sites, can definitely be challenging. For many simple sites, though, where all content
24
-
is served by the same domain (http://example.com), it is very simple to integrate.
24
+
is served by the same domain (e.g., **http://example.com**), it is very simple to integrate.
25
25
26
26
As this is a complex subject, this user guide will not go over all of the details. For more information, you should
27
27
visit the following sites:
@@ -88,7 +88,12 @@ Inline Content
88
88
89
89
It is possible to set a website to not protect even inline scripts and styles on its own pages, since this might have
90
90
been the result of user-generated content. To protect against this, CSP allows you to specify a nonce within the
91
-
``<style>`` and ``<script>`` tags, and to add those values to the response's header. This is a pain to handle in real
91
+
``<style>`` and ``<script>`` tags, and to add those values to the response's header.
92
+
93
+
Using Placeholders
94
+
==================
95
+
96
+
This is a pain to handle in real
92
97
life, and is most secure when generated on the fly. To make this simple, you can include a ``{csp-style-nonce}`` or
93
98
``{csp-script-nonce}`` placeholder in the tag and it will be handled for you automatically::
94
99
@@ -109,7 +114,13 @@ life, and is most secure when generated on the fly. To make this simple, you can
109
114
110
115
.. warning:: If an attacker injects a string like ``<script {csp-script-nonce}>``, it might become the real nonce attribute with this functionality. You can customize the placeholder string with the ``$scriptNonceTag`` and ``$styleNonceTag`` properties in **app/Config/ContentSecurityPolicy.php**.
111
116
112
-
If you don't like this auto replacement functionality, you can turn it off with setting ``$autoNonce = false`` in **app/Config/ContentSecurityPolicy.php**.
117
+
.. _csp-using-functions:
118
+
119
+
Using Functions
120
+
===============
121
+
122
+
If you don't like the auto replacement functionality above, you can turn it off
123
+
with setting ``$autoNonce = false`` in **app/Config/ContentSecurityPolicy.php**.
113
124
114
125
In this case, you can use the functions, :php:func:`csp_script_nonce()` and :php:func:`csp_style_nonce()`::
0 commit comments