| api_security_headers | R Documentation |
This function adds the SecurityHeaders plugin to your plumber2 API. Please consult the documentation for the plugin for up-to-date information on its behaviour.
api_security_headers(
api,
content_security_policy = 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),
content_security_policy_report_only = NULL,
cross_origin_embedder_policy = NULL,
cross_origin_opener_policy = "same-origin",
cross_origin_resource_policy = "same-origin",
origin_agent_cluster = TRUE,
referrer_policy = "no-referrer",
strict_transport_security = sts(max_age = 63072000, include_sub_domains = TRUE),
x_content_type_options = TRUE,
x_dns_prefetch_control = FALSE,
x_download_options = TRUE,
x_frame_options = "SAMEORIGIN",
x_permitted_cross_domain_policies = "none",
x_xss_protection = FALSE
)
api |
A plumber2 api object to add the plugin to |
content_security_policy |
Set the value of the |
content_security_policy_report_only |
Set the value of the
|
cross_origin_embedder_policy |
Set the value of the
|
cross_origin_opener_policy |
Set the value of the
|
cross_origin_resource_policy |
Set the value of the
|
origin_agent_cluster |
Set the value of the
|
referrer_policy |
Set the value of the
|
strict_transport_security |
Set the value of the
|
x_content_type_options |
Set the value of the
|
x_dns_prefetch_control |
Set the value of the
|
x_download_options |
Set the value of the
|
x_frame_options |
Set the value of the
|
x_permitted_cross_domain_policies |
Set the value of the
|
x_xss_protection |
Set the value of the
|
This functions return the api object allowing for easy chaining
with the pipe
Security headers doesn't have a dedicated annotation tag, but you can set
it up in a @plumber block
#* @plumber
function(api) {
api |>
api_security_headers()
}
Other security features:
api_security_cors(),
api_security_resource_isolation()
# Add default security headers to an API
api() |>
api_security_headers()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.