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
+
112
+
Note: This doesn't use ``default-src`` as a fall-back.
113
+
84
114
``CSP_MANIFEST_SRC``
85
-
Set the ``manifest-src`` directive. A tuple or list. *None*
115
+
Set the ``manifest-src`` directive. A ``tuple`` or ``list``. *None*
116
+
86
117
``CSP_WORKER_SRC``
87
-
Set the ``worker-src`` directive. A tuple or list. *None*
118
+
Set the ``worker-src`` directive. A ``tuple`` or ``list``. *None*
119
+
88
120
``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.
121
+
Set the ``plugin-types`` directive. A ``tuple`` or ``list``. *None*
122
+
123
+
Note: This doesn't use ``default-src`` as a fall-back.
124
+
91
125
``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.
126
+
Set the ``require-sri-for`` directive. A ``tuple`` or ``list``. *None*
127
+
Valid values: ``script``, ``style``, or both.
128
+
129
+
See: require-sri-for-known-tokens_
130
+
131
+
Note: This doesn't use ``default-src`` as a fall-back.
132
+
95
133
``CSP_UPGRADE_INSECURE_REQUESTS``
96
-
Include ``upgrade-insecure-requests`` directive. A boolean. *False*
134
+
Include ``upgrade-insecure-requests`` directive. A ``boolean``. *False*
135
+
97
136
See: upgrade-insecure-requests_
137
+
98
138
``CSP_REQUIRE_TRUSTED_TYPES_FOR``
99
-
Include ``reuire-trusted-types-for`` directive. A tuple or list. *None*
139
+
Include ``reuire-trusted-types-for`` directive.
140
+
A ``tuple`` or ``list``. *None*
141
+
100
142
Valid values: ``'script'``
101
-
Note: This doesn't use default-src as a fall-back.
143
+
144
+
Note: This doesn't use ``default-src`` as a fall-back.
145
+
102
146
``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.
147
+
Include ``trusted-types`` directive.
148
+
A ``tuple`` or ``list``. *None*
149
+
150
+
Valid values: a list of allowed policy names that may include
151
+
``default`` and/or ``'allow-duplicates'``
152
+
153
+
Note: This doesn't use ``default-src`` as a fall-back.
154
+
106
155
``CSP_BLOCK_ALL_MIXED_CONTENT``
107
-
Include ``block-all-mixed-content`` directive. A boolean. *False*
156
+
Include ``block-all-mixed-content`` directive. A ``boolean``. *False*
157
+
108
158
See: block-all-mixed-content_
159
+
109
160
``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*
161
+
Include dynamically generated nonce in all listed directives.
162
+
A ``tuple`` or ``list``, e.g.: ``CSP_INCLUDE_NONCE_IN = ['script-src']``
163
+
will add ``'nonce-<b64-value>'`` to the ``script-src`` directive.
164
+
*['default-src']*
165
+
166
+
Note: The nonce value will only be included if ``request.cps_nonce``
167
+
is accessed during the request/response cycle.
111
168
112
169
113
170
Changing the Policy
@@ -124,22 +181,25 @@ These settings control the behavior of django-csp. Defaults are in
124
181
*italics*.
125
182
126
183
``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*
184
+
Send "report-only" headers instead of real headers.
185
+
A ``boolean``. *False*
186
+
187
+
See the spec_ and the chapter on :ref:`reports <reports-chapter>` for
188
+
more info.
189
+
130
190
``CSP_EXCLUDE_URL_PREFIXES``
131
-
A **tuple** of URL prefixes. URLs beginning with any of these will
191
+
A ``tuple`` of URL prefixes. URLs beginning with any of these will
132
192
not get the CSP headers. *()*
133
193
134
194
.. warning::
135
195
136
196
Excluding any path on your site will eliminate the benefits of CSP
137
197
everywhere on your site. The typical browser security model for
138
198
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.
199
+
on, e.g., ``excluded-page/`` can therefore be leveraged to access
0 commit comments