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
Set the ``script-src`` directive. A tuple or list. *None*
34
+
Set the ``script-src`` directive. A ``tuple`` or ``list``. *None*
35
+
35
36
``CSP_SCRIPT_SRC_ATTR``
36
-
Set the ``script-src-attr`` directive. A tuple or list. *None*
37
+
Set the ``script-src-attr`` directive. A ``tuple`` or ``list``. *None*
38
+
37
39
``CSP_SCRIPT_SRC_ELEM``
38
-
Set the ``script-src-elem`` directive. A tuple or list. *None*
40
+
Set the ``script-src-elem`` directive. A ``tuple`` or ``list``. *None*
41
+
39
42
``CSP_IMG_SRC``
40
-
Set the ``img-src`` directive. A tuple or list. *None*
43
+
Set the ``img-src`` directive. A ``tuple`` or ``list``. *None*
44
+
41
45
``CSP_OBJECT_SRC``
42
-
Set the ``object-src`` directive. A tuple or list. *None*
46
+
Set the ``object-src`` directive. A ``tuple`` or ``list``. *None*
47
+
43
48
``CSP_PREFETCH_SRC``
44
-
Set the ``prefetch-src`` directive. A tuple or list. *None*
49
+
Set the ``prefetch-src`` directive. A ``tuple`` or ``list``. *None*
50
+
45
51
``CSP_MEDIA_SRC``
46
-
Set the ``media-src`` directive. A tuple or list. *None*
52
+
Set the ``media-src`` directive. A ``tuple`` or ``list``. *None*
53
+
47
54
``CSP_FRAME_SRC``
48
-
Set the ``frame-src`` directive. A tuple or list. *None*
55
+
Set the ``frame-src`` directive. A ``tuple`` or ``list``. *None*
56
+
49
57
``CSP_FONT_SRC``
50
-
Set the ``font-src`` directive. A tuple or list. *None*
58
+
Set the ``font-src`` directive. A ``tuple`` or ``list``. *None*
59
+
51
60
``CSP_CONNECT_SRC``
52
-
Set the ``connect-src`` directive. A tuple or list. *None*
61
+
Set the ``connect-src`` directive. A ``tuple`` or ``list``. *None*
62
+
53
63
``CSP_STYLE_SRC``
54
-
Set the ``style-src`` directive. A tuple or list. *None*
64
+
Set the ``style-src`` directive. A ``tuple`` or ``list``. *None*
65
+
55
66
``CSP_STYLE_SRC_ATTR``
56
-
Set the ``style-src-attr`` directive. A tuple or list. *None*
67
+
Set the ``style-src-attr`` directive. A ``tuple`` or ``list``. *None*
68
+
57
69
``CSP_STYLE_SRC_ELEM``
58
-
Set the ``style-src-elem`` directive. A tuple or list. *None*
70
+
Set the ``style-src-elem`` directive. A ``tuple`` or ``list``. *None*
71
+
59
72
``CSP_BASE_URI``
60
-
Set the ``base-uri`` directive. A tuple or list. *None*
61
-
Note: This doesn't use default-src as a fall-back.
73
+
Set the ``base-uri`` directive. A ``tuple`` or ``list``. *None*
74
+
75
+
Note: This doesn't use ``default-src`` as a fall-back.
76
+
62
77
``CSP_CHILD_SRC``
63
-
Set the ``child-src`` directive. A tuple or list. *None*
78
+
Set the ``child-src`` directive. A ``tuple`` or ``list``. *None*
79
+
64
80
``CSP_FRAME_ANCESTORS``
65
-
Set the ``frame-ancestors`` directive. A tuple or list. *None*
66
-
Note: This doesn't use default-src as a fall-back.
81
+
Set the ``frame-ancestors`` directive. A ``tuple`` or ``list``. *None*
82
+
83
+
Note: This doesn't use ``default-src`` as a fall-back.
84
+
67
85
``CSP_NAVIGATE_TO``
68
-
Set the ``navigate-to`` directive. A tuple or list. *None*
69
-
Note: This doesn't use default-src as a fall-back.
86
+
Set the ``navigate-to`` directive. A ``tuple`` or ``list``. *None*
87
+
88
+
Note: This doesn't use ``default-src`` as a fall-back.
89
+
70
90
``CSP_FORM_ACTION``
71
-
Set the ``FORM_ACTION`` directive. A tuple or list. *None*
72
-
Note: This doesn't use default-src as a fall-back.
91
+
Set the ``FORM_ACTION`` directive. A ``tuple`` or ``list``. *None*
92
+
93
+
Note: This doesn't use ``default-src`` as a fall-back.
94
+
73
95
``CSP_SANDBOX``
74
-
Set the ``sandbox`` directive. A tuple or list. *None*
75
-
Note: This doesn't use default-src as a fall-back.
96
+
Set the ``sandbox`` directive. A ``tuple`` or ``list``. *None*
97
+
98
+
Note: This doesn't use ``default-src`` as a fall-back.
99
+
76
100
``CSP_REPORT_URI``
77
-
Set the ``report-uri`` directive. A tuple or list. Each URI can be a
78
-
full or relative URI. *None*
79
-
Note: This doesn't use default-src as a fall-back.
101
+
Set the ``report-uri`` directive. A ``tuple`` or ``list`` of URIs.
102
+
Each URI can be a full or relative URI. *None*
103
+
104
+
Note: This doesn't use ``default-src`` as a fall-back.
105
+
80
106
``CSP_REPORT_TO``
81
-
Set the ``report-to`` directive. A string describing a reporting group. *None*
82
-
Note: This doesn't use default-src as a fall-back.
107
+
Set the ``report-to`` directive. A ``string`` describing a reporting
108
+
group. *None*
109
+
83
110
See Section 1.2: https://w3c.github.io/reporting/#group
111
+
84
112
``CSP_MANIFEST_SRC``
85
-
Set the ``manifest-src`` directive. A tuple or list. *None*
113
+
Set the ``manifest-src`` directive. A ``tuple`` or ``list``. *None*
114
+
86
115
``CSP_WORKER_SRC``
87
-
Set the ``worker-src`` directive. A tuple or list. *None*
116
+
Set the ``worker-src`` directive. A ``tuple`` or ``list``. *None*
117
+
88
118
``CSP_PLUGIN_TYPES``
89
-
Set the ``plugin-types`` directive. A tuple or list. *None*
90
-
Note: This doesn't use default-src as a fall-back.
119
+
Set the ``plugin-types`` directive. A ``tuple`` or ``list``. *None*
120
+
91
121
``CSP_REQUIRE_SRI_FOR``
92
-
Set the ``require-sri-for`` directive. A tuple or list. *None*
93
-
Valid values: ``script``, ``style``, or both. See: require-sri-for-known-tokens_
94
-
Note: This doesn't use default-src as a fall-back.
122
+
Set the ``require-sri-for`` directive. A ``tuple`` or ``list``. *None*
123
+
124
+
Valid values: a ``list`` containing ``'script'``, ``'style'``, or both.
125
+
126
+
See: require-sri-for-known-tokens_
127
+
95
128
``CSP_UPGRADE_INSECURE_REQUESTS``
96
-
Include ``upgrade-insecure-requests`` directive. A boolean. *False*
129
+
Include ``upgrade-insecure-requests`` directive. A ``boolean``. *False*
130
+
97
131
See: upgrade-insecure-requests_
132
+
98
133
``CSP_REQUIRE_TRUSTED_TYPES_FOR``
99
-
Include ``reuire-trusted-types-for`` directive. A tuple or list. *None*
100
-
Valid values: ``'script'``
101
-
Note: This doesn't use default-src as a fall-back.
134
+
Include ``require-trusted-types-for`` directive.
135
+
A ``tuple`` or ``list``. *None*
136
+
137
+
Valid values: ``["'script'"]``
138
+
102
139
``CSP_TRUSTED_TYPES``
103
-
Include ``trusted-types`` directive. A tuple of list. *This header is empty by default*
104
-
Valid values: a list of allowed policy names that may include ``default`` and/or ``'allow-duplicates'``
105
-
Note: This doesn't use default-src as a fall-back.
140
+
Include ``trusted-types`` directive.
141
+
A ``tuple`` or ``list``. *None*
142
+
143
+
Valid values: a ``list`` of allowed policy names that may include
144
+
``default`` and/or ``'allow-duplicates'``
145
+
106
146
``CSP_BLOCK_ALL_MIXED_CONTENT``
107
-
Include ``block-all-mixed-content`` directive. A boolean. *False*
147
+
Include ``block-all-mixed-content`` directive. A ``boolean``. *False*
148
+
108
149
See: block-all-mixed-content_
150
+
109
151
``CSP_INCLUDE_NONCE_IN``
110
-
Include dynamically generated nonce in all listed directives, e.g. ``CSP_INCLUDE_NONCE_IN=['script-src']`` will add ``'nonce-<b64-value>'`` to the ``script-src`` directive. A tuple or list. *None*
152
+
Include dynamically generated nonce in all listed directives.
153
+
A ``tuple`` or ``list``, e.g.: ``CSP_INCLUDE_NONCE_IN = ['script-src']``
154
+
will add ``'nonce-<b64-value>'`` to the ``script-src`` directive.
155
+
*['default-src']*
156
+
157
+
Note: The nonce value will only be generated if ``request.cps_nonce``
158
+
is accessed during the request/response cycle.
111
159
112
160
113
161
Changing the Policy
@@ -124,22 +172,25 @@ These settings control the behavior of django-csp. Defaults are in
124
172
*italics*.
125
173
126
174
``CSP_REPORT_ONLY``
127
-
Send "report-only" headers instead of real headers. See the spec_
128
-
and the chapter on :ref:`reports <reports-chapter>` for more info. A
129
-
boolean. *False*
175
+
Send "report-only" headers instead of real headers.
176
+
A ``boolean``. *False*
177
+
178
+
See the spec_ and the chapter on :ref:`reports <reports-chapter>` for
179
+
more info.
180
+
130
181
``CSP_EXCLUDE_URL_PREFIXES``
131
-
A **tuple** of URL prefixes. URLs beginning with any of these will
132
-
not get the CSP headers. *()*
182
+
A ``tuple`` (*not* a ``list``) of URL prefixes. URLs beginning with any
183
+
of these will not get the CSP headers. *()*
133
184
134
185
.. warning::
135
186
136
187
Excluding any path on your site will eliminate the benefits of CSP
137
188
everywhere on your site. The typical browser security model for
138
189
JavaScript considers all paths alike. A Cross-Site Scripting flaw
139
-
on, e.g., `excluded-page/` can therefore be leveraged to access everything
140
-
on the same origin.
190
+
on, e.g., ``excluded-page/`` can therefore be leveraged to access
0 commit comments