View source: R/SecurityHeaders_helpers.R
csp | R Documentation |
Content-Security-Policy
headerThis helper function exists mainly to document the possible values and prevent misspelled directives. It returns a bare list. See the header reference and the CSP section of the MDN security guide for more information on the header
csp(
default_src = NULL,
script_src = NULL,
script_src_elem = NULL,
script_src_attr = NULL,
style_src = NULL,
style_src_elem = NULL,
style_src_attr = NULL,
img_src = NULL,
font_src = NULL,
media_src = NULL,
object_src = NULL,
child_src = NULL,
frame_src = NULL,
worker_src = NULL,
connect_src = NULL,
fenced_frame_src = NULL,
manifest_src = NULL,
prefetch_src = NULL,
base_uri = NULL,
sandbox = FALSE,
form_action = NULL,
frame_ancestors = NULL,
report_to = NULL,
require_trusted_types_for = FALSE,
trusted_types = NULL,
upgrade_insecure_requests = FALSE
)
default_src |
Fallback for all other |
script_src |
Fallback for |
script_src_elem |
Valid sources for |
script_src_attr |
Valid sources for inline event handlers |
style_src |
Fallback for |
style_src_elem |
Valid sources for |
style_src_attr |
Valid sources for inline styling of elements |
img_src |
Valid sources for images and favicons |
font_src |
Valid sources for fonts loaded with |
media_src |
Valid sources for |
object_src |
Valid sources for |
child_src |
Fallback for |
frame_src |
Valid sources for |
worker_src |
Valid sources for |
connect_src |
Valid sources for URLs loaded from within scripts |
fenced_frame_src |
Valid sources for |
manifest_src |
Valid sources for application manifest files |
prefetch_src |
Valid sources to be prefetched and prerendered |
base_uri |
Valid sources that can be put in a |
sandbox |
Logical. Enable sandboxing of the requested document/ressource |
form_action |
Valid URLs to be targeted by form submissions |
frame_ancestors |
Valid parents that may embed this document in an
|
report_to |
A URL to report violations to. Setting this will also add
a |
require_trusted_types_for |
Logical. Enforces Trusted Types |
trusted_types |
Specifies an allow list of Trusted Types |
upgrade_insecure_requests |
Logical. Automatically treat all HTTP urls in the document as if they were HTTPS |
A bare list with the input arguments
# Default setting
csp(
default_src = "self",
script_src = "self",
script_src_attr = "none",
style_src = c("self", "https:", "unsafe-inline"),
img_src = c("self", "data:"),
font_src = c("self", "https:", "data:"),
object_src = "none",
base_uri = "self",
form_action = "self",
frame_ancestors = "self",
upgrade_insecure_requests = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.