| Title: | A Collection of Security Related Plugins for 'fiery' |
|---|---|
| Description: | Provide a range of plugins for 'fiery' web servers that handle different aspects of server-side web security. Be aware that security cannot be handled blindly, and even though these plugins will raise the security of your server you should not build critical infrastructure without the aid of a security expert. |
| Authors: | Thomas Lin Pedersen [aut, cre] (ORCID: <https://orcid.org/0000-0002-5147-4711>), Posit Software, PBC [cph, fnd] (ROR: <https://ror.org/03wc8by49>) |
| Maintainer: | Thomas Lin Pedersen <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0.9000 |
| Built: | 2026-05-18 08:49:01 UTC |
| Source: | https://github.com/thomasp85/firesafety |
Cross-Origin Resource Sharing (CORS) is a mechanism for servers to indicate from where it may be accessed and allows browsers to block requests that are not permitted. For security reasons, browsers limits requests initiated from JavaScript to only those for the same site. To allow requests from other sites the server needs to send the right CORS headers with the response. Read more about CORS at MDN
CORS is opt-in. The security measure is already in place in browsers to limit cross-origin requests, and CORS is a way to break out of this in a controlled manner where you can indicate exactly who can make a request and what requests can be made. In general it works like this:
A request is being initiated from a website, either through JavaScript or another venue, to a site different than the one it originates from.
The browser identifies that the request is cross-origin and sends an
OPTIONS request to the server with information about the request it
intends to send (this is called a pre-flight request).
The server responds with a 204 response giving the allowed types of requests that can be made for the resource.
If the original request conforms to the response the browser will then send the actual request.
The server responds to the actual request.
The client gets the response, but the browser will limit what information in the response it can access based on the information provided by the server in the pre-flight response.
As can be seen, a CORS request is slightly more complex than the standard request-response you normally think about. However, the pre-flight request can be cached by the browser and so, will not happen every time a ressource is accessed. While a site may employ a CORS policy the same way across all its endpoints it does not need to. It is fine to only turn on CORS for a subset of paths. In general it is a good rule of thumb to set up resource isolation for the paths that do not have CORS enabled.
A new 'CORS'-object is initialized using the new() method on the
generator and pass in any settings deviating from the defaults
Usage
cors <- CORS$new(...)
|
A CORS object is a fiery plugin and can be used by passing it
to the attach() method of the fiery server object. Once attached all
requests will be passed through the plugin and the policy applied to it
nameThe name of the plugin
new()
Initialize a CORS object
CORS$new(
path = "/*",
origin = "*",
methods = c("get", "head", "put", "patch", "post", "delete"),
allowed_headers = NULL,
exposed_headers = NULL,
allow_credentials = FALSE,
max_age = NULL
)pathThe path that the policy should apply to. routr path syntax applies, meaning that wilcards and path parameters are allowed.
originThe origin allowed for the path. Can be one of:
A boolean. If TRUE then all origins are permitted and the preflight
response will have the Access-Control-Allow-Origin header reflect
the origin of the request. If FALSE then all origins are denied
The string "*" which will allow all origins and set
Access-Control-Allow-Origin to *. This is different than setting it
to TRUE because * instructs browsers that any origin is allowed and
it may use this information when searching the cache
A character vector giving allowed origins. If the request origin
matches any of these then the Access-Control-Allow-Origin header in
the response will reflect the origin of the request
A function taking the request and returning TRUE if the origin is
permitted and FALSE if it is not. If permitted the
Access-Control-Allow-Origin header will reflect the request origin
methodsThe HTTP methods allowed for the path
allowed_headersA character vector of request headers allowed when
making the request. If the request contains headers not permitted, then
the response will be blocked by the browser. NULL will allow any header
by reflecting the Access-Control-Request-Headers header value from the
request into the Access-Control-Allow-Headers header in the response.
exposed_headersA character vector of response headers that should be made available to the client upon a succesful request
allow_credentialsA boolean indicating whether credentials are
allowed in the request. Credentials are cookies or HTTP authentication
headers, which are normally stripped from fetch() requests by the
browser. If this is TRUE then origin cannot be * according to the
spec
max_ageThe duration browsers are allowed to keep the preflight response in the cache
add_path()
Add CORS settings to a path
CORS$add_path(
path = "/*",
origin = "*",
methods = c("get", "head", "put", "patch", "post", "delete"),
allowed_headers = NULL,
exposed_headers = NULL,
allow_credentials = FALSE,
max_age = NULL
)pathThe path that the policy should apply to. routr path syntax applies, meaning that wilcards and path parameters are allowed.
originThe origin allowed for the path. Can be one of:
A boolean. If TRUE then all origins are permitted and the preflight
response will have the Access-Control-Allow-Origin header reflect
the origin of the request. If FALSE then all origins are denied
The string "*" which will allow all origins and set
Access-Control-Allow-Origin to *. This is different than setting it
to TRUE because * instructs browsers that any origin is allowed and
it may use this information when searching the cache
A character vector giving allowed origins. If the request origin
matches any of these then the Access-Control-Allow-Origin header in
the response will reflect the origin of the request
A function taking the request and returning TRUE if the origin is
permitted and FALSE if it is not. If permitted the
Access-Control-Allow-Origin header will reflect the request origin
methodsThe HTTP methods allowed for the path
allowed_headersA character vector of request headers allowed when
making the request. If the request contains headers not permitted, then
the response will be blocked by the browser. NULL will allow any header
by reflecting the Access-Control-Request-Headers header value from the
request into the Access-Control-Allow-Headers header in the response.
exposed_headersA character vector of response headers that should be made available to the client upon a succesful request
allow_credentialsA boolean indicating whether credentials are
allowed in the request. Credentials are cookies or HTTP authentication
headers, which are normally stripped from fetch() requests by the
browser. If this is TRUE then origin cannot be * according to the
spec
max_ageThe duration browsers are allowed to keep the preflight response in the cache
on_attach()
Method for use by fiery when attached as a plugin. Should
not be called directly.
CORS$on_attach(app, ...)
appThe fiery server object
...Ignored
clone()
The objects of this class are cloneable with this method.
CORS$clone(deep = FALSE)
deepWhether to make a deep clone.
# Setup CORS for a sub path allowing access from www.trustworthy.com # Tell the browser to cache the preflight for a day cors <- CORS$new( path = "/shared_assets/*", origin = "https://www.trustworthy.com", methods = c("get", "head", "post"), max_age = 86400 ) # Use it in a fiery server app <- fiery::Fire$new() app$attach(cors)# Setup CORS for a sub path allowing access from www.trustworthy.com # Tell the browser to cache the preflight for a day cors <- CORS$new( path = "/shared_assets/*", origin = "https://www.trustworthy.com", methods = c("get", "head", "post"), max_age = 86400 ) # Use it in a fiery server app <- fiery::Fire$new() app$attach(cors)
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 )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 )# 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 )
This plugin uses the information provided in the Sec-Fetch-* request
headers to block unwanted requests to your server coming from other sites.
Setting up a strict control with which requests are allowed is an important
part of preventing some cross-site leaks as well as cross-site request
forgery attacks.
Compared to the other security measures in firesafety, the reource isolation plugin is a server-side blocker of requests. Both CORS and CORP sends back a full response and it is then up to the browser to determine if the response becomes available to the site. In contrast, this plugin will return a 403 response if the request fails to be accepted. This is not to say that resource isolation is better than CORS, CORP or other measures. They all target different situations (or the same situation from different angles) and works best in unison. You can read more about this type of defence at MDN and XS-Leaks Wiki
Resource isolation takes advantage of the Sec-Fetch-* headers that browser
send along with requests. These headers informs the server about the nature
of the request. Where it comes from, what action initiated it, and how it
will be used. Based on this information the server may chose to allow a
request to proceed or deny it altogether. This plugin runs a request through
a range of tests and if it passes any of them it proceeds:
Does the request have the Sec-Fetch-* headers
Is allow_cors == TRUE and is Sec-Fetch-Mode set to cors
Is Sec-Fetch-Site set to allowed_site or a more restrictive value
Is the request method GET, the Sec-Fetch-Mode navigation, and the
Sec-Fetch-Dest not one of those given by forbidden_navigation
You can have different permissions for different paths. The default during
initialization is to add it to /* so that all all paths will share the same
policy, but you can strengthen or loosen up specific paths as needed. A good
rule of thumb is to make the policy as restrictive as possible while allowing
your application to still work as intented. Further, if you have paths that
do not have a resource isolation policy in place these should have CORS
enabled.
A new 'ResourceIsolation'-object is initialized using the new() method on the
generator and pass in any settings deviating from the defaults
Usage
resource_isolation <- ResourceIsolation$new(...)
|
A ResourceIsolation object is a fiery plugin and can be used by passing it
to the attach() method of the fiery server object. Once attached all
requests will be passed through the plugin and the policy applied to it
nameThe name of the plugin
new()
Initialize a new ResourceIsolation object
ResourceIsolation$new(
path = "/*",
allowed_site = "same-site",
forbidden_navigation = c("object", "embed"),
allow_cors = TRUE
)pathThe path that the policy should apply to. routr path syntax applies, meaning that wilcards and path parameters are allowed.
allowed_siteThe allowance level to permit. Either cross-site,
same-site, or same-origin.
forbidden_navigationA vector of destinations not allowed for
navigational requests. See the Sec-Fetch-Dest documentation
for a description of possible values. The special value "all" is also
permitted which is the equivalent of passing all values.
allow_corsShould Sec-Fetch-Mode: cors requests be allowed
add_path()
Add a policy to a path
ResourceIsolation$add_path(
path,
allowed_site,
forbidden_navigation = c("object", "embed"),
allow_cors = TRUE
)pathThe path that the policy should apply to. routr path syntax applies, meaning that wilcards and path parameters are allowed.
allowed_siteThe allowance level to permit. Either cross-site,
same-site, or same-origin.
forbidden_navigationA vector of destinations not allowed for
navigational requests. See the Sec-Fetch-Dest documentation
for a description of possible values. The special value "all" is also
permitted which is the equivalent of passing all values.
allow_corsShould Sec-Fetch-Mode: cors requests be allowed
on_attach()
Method for use by fiery when attached as a plugin. Should
not be called directly.
ResourceIsolation$on_attach(app, ...)
appThe fiery server object
...Ignored
clone()
The objects of this class are cloneable with this method.
ResourceIsolation$clone(deep = FALSE)
deepWhether to make a deep clone.
# Create resource isolation policy denying all navigation requests resource_isolation <- ResourceIsolation$new(forbidden_navigation = "all") # Allow cross-site requests on a subpath resource_isolation$add_path( path = "/all_is_welcome/*", allowed_site = "cross-site" ) # Use it in a fiery server app <- fiery::Fire$new() app$attach(resource_isolation)# Create resource isolation policy denying all navigation requests resource_isolation <- ResourceIsolation$new(forbidden_navigation = "all") # Allow cross-site requests on a subpath resource_isolation$add_path( path = "/all_is_welcome/*", allowed_site = "cross-site" ) # Use it in a fiery server app <- fiery::Fire$new() app$attach(resource_isolation)
This plugin is inspired by Helmet.js and aids
you in setting response headers relevant for security of your fiery server.
All defaults are taken from Helmet.js as well, except for the max-age of the
Strict-Transport-Security header that has been doubled to 2 years which is
the recommendation.
Web security is a complicated subject and it is impossible for this document to stay current and true at all times as well as be able to learn the user of all the intricacies of web security. It is strongly advised that you familiarise yourself with this subject if you plan on exposing a fiery webserver to the public. A good starting point is MDN's guide on web security.
This plugin concerns 14 different headers that are in one way or another
implicated in security. Some of them are only relevant if you serve HTML
content on the web and have no effect on e.g. a server providing a REST api.
These have been marked with UI below. While you may turn these off for a
pure API server (by setting them to NULL), it is advised that you only
steer away from the defaults if you have a good grasp of the implications.
The headers are set very efficiently so removing some unneeded ones will only
have an effect on the size of the response, not the handling time.
Content-Security-Policy (UI)This header provides finely grained control over what code can be executed on the site you provide and thus help in preventing cross-site scripting (XSS) attacks. The configuration of this header is complicated and you can read more about it at the header reference and the CSP section of the security guide
The plugin does some light validation of the data structure you provide and
you can use the csp() constructure to get argument tab-completion.
Content-Security-Policy-Report-Only (UI)This header is like Content-Security-Policy above except that it doesn't
enforce the policy but rather report any violations to a URL of your choice.
The reason for providing this is that setting up CSP correctly can be
difficult and may lead to your site not working correctly. Therefore, if you
apply CSP to an already excisting site it is often a good idea to start with
using this header and monitor where issues may arise before turning on the
policy fully. You provide the URL to send violation reports to with the
report_to directive which should be set to a URL. You can find more
information on this header at
the header reference
Cross-Origin-Embedder-Policy (UI)This header controls which resources can be embedded in a document. If set
to e.g. require-corp then only resources that implements CORP or CORS can
be embedded. It is not set by default in SecurityHeaders. Read more about this
header at MDN
Cross-Origin-Opener-Policy (UI)This header controls and restricts access from cross-origin windows opened from the site. It helps isolate new documents and prevent a type of attack known as XS-Leaks. Read more about this header at MDN and about XS-Leaks in the security guide
Cross-Origin-Resource-PolicyThis header controls where the given response can be used. If you e.g. return
an image along with Cross-Origin-Resource-Policy: same-site, then this
image is blocked from being loaded by other sites.
Read more about this header at MDN
and about CORP in general in the security guide
Origin-Agent-Cluster (UI)This header helps isolate documents served from the same site into separate processes. This can improve performance of other tabs if a resource intensive tab is opened but also prevent certain information from being available to code running in the tab. Read more about this header at MDN
Referrer-Policy (UI)This header instructs what to include in the Referer header when navigating
away from the document. This can potentially lead to information leakage
which can be alleviated using this header. Read more about this header at
MDN
as well as the security implications of the Referer header
Strict-Transport-SecurityThis header informs a browser that the given resource should only be accessed using HTTPS. This preference is cached by the browser and the next time the resource is accessed over HTTP it is automatically changed to HTTPS before the request is made. This header should only be sent over HTTPS to prevent a manipulator-in-the-middle from alterning its settings. In order for this to happen SecurityHeaders will automatically redirect any HTTP requests to HTTPS if this header is set. Read more about this header at MDN
X-Content-Type-OptionsThis header instruct the client that the MIME type provided by the
Content-Type should be respected and mime-type sniffing avoided. Setting
this can help prevent certain XSS attacks. Read more about this header at
MDN
and about its security implication in the
security guide
X-DNS-Prefetch-Control (UI)This header controls DNS prefetching and domain name resolution. A browser may do this in the background when a site is loaded which can reduce latency when a user clicks a link. However, it may also leak sensitive information so turning it off may increase user privacy. Read more about this header at MDN
X-Download-Options (UI)This is an old header only relevant to Internet Explorer 8 and below that prevents downloaded content from having access to your site's context.
X-Frame-Options (UI)This header has been superseeded by the frame-ancestor directive in the
Content-Security-Policy header but may still be good to set for older
browsers. It controls whether a site is allowed to be rendered inside a frame
in another document. Preventing this can prevent click-jacking attacks. Read
more about this header at MDN
X-Permitted-Cross-Domain-PoliciesThis header controls cross-origin access of a resource from a document running in a web client such as Adobe Flash Player or Microsoft Silverlight. The demise of these technologies have made this header less important. Read more about this header at MDN
X-XSS-Protection (UI)This header has been deprecated in favor of the more powerful
Content-Security-Policy header. In fact using XSS filtering can incur a
security vulnerability which is why the default for SecurityHeaders is to turn the
feature off (by setting X-XSS-Protection: 0 rather than omitting the
header). Read more about this header at
MDN
A new 'SecurityHeaders'-object is initialized using the new() method on the
generator and pass in any settings deviating from the defaults
Usage
security_headers <- SecurityHeaders$new(...)
|
A SecurityHeaders object is a fiery plugin and can be used by passing it to the
attach() method of the fiery server object. Once attached all requests
created will be prepopulated with the given headers. Any request handler is
permitted to remove one or more of the headers to opt out of them.
content_security_policySet or get the value of the
Content-Security-Policy header. See csp() for documentation of its
values
content_security_policy_report_onlySet or get the value of the
Content-Security-Policy-Report-Only header. See csp() for
documentation of its values
cross_origin_embedder_policySet or get the value of the
Cross-Origin-Embedder-Policy. Possible values are "unsafe-none",
"require-corp", and "credentialless"
cross_origin_opener_policySet or get the value of the
Cross-Origin-Opener-Policy. Possible values are "unsafe-none",
"same-origin-allow-popups", "same-origin", and
"noopener-allow-popups"
cross_origin_resource_policySet or get the value of the
Cross-Origin-Resource-Policy. Possible values are "same-site",
"same-origin", and "cross-origin"
origin_agent_clusterSet or get the value of the
Origin-Agent-Cluster. Possible values are TRUE and FALSE
referrer_policySet or get the value of the
Referrer-Policy. Possible values are "no-referrer",
"no-referrer-when-downgrade", "origin", "origin-when-cross-origin",
"same-origin", "strict-origin", "strict-origin-when-cross-origin",
and "unsafe-url"
strict_transport_securitySet or get the value of the
Strict-Transport-Security header. See sts() for documentation of its
values
x_content_type_optionsSet or get the value of the
X-Content-Type-Options. Possible values are TRUE and FALSE
x_dns_prefetch_controlSet or get the value of the
X-DNS-Prefetch-Control. Possible values are TRUE and FALSE
x_download_optionsSet or get the value of the
X-Download-Options. Possible values are TRUE and FALSE
x_frame_optionsSet or get the value of the
X-Frame-Options. Possible values are "DENY" and "SAMEORIGIN"
x_permitted_cross_domain_policiesSet or get the value of the
X-Permitted-Cross-Domain-Policies. Possible values are "none",
"master-only", "by-content-type", "by-ftp-filename", "all", and
"none-this-response"
x_xss_protectionSet or get the value of the
X-XSS-Protection. Possible values are TRUE and FALSE
nameThe name of the plugin
new()
Initialize a new SecurityHeaders object
SecurityHeaders$new(
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
)content_security_policySet the value of the Content-Security-Policy
header. See csp() for documentation of its values
content_security_policy_report_onlySet the value of the
Content-Security-Policy-Report-Only header. See csp() for
documentation of its values
cross_origin_embedder_policySet the value of the
Cross-Origin-Embedder-Policy. Possible values are "unsafe-none",
"require-corp", and "credentialless"
cross_origin_opener_policySet the value of the
Cross-Origin-Opener-Policy. Possible values are "unsafe-none",
"same-origin-allow-popups", "same-origin", and
"noopener-allow-popups"
cross_origin_resource_policySet the value of the
Cross-Origin-Resource-Policy. Possible values are "same-site",
"same-origin", and "cross-origin"
origin_agent_clusterSet the value of the
Origin-Agent-Cluster. Possible values are TRUE and FALSE
referrer_policySet the value of the
Referrer-Policy. Possible values are "no-referrer",
"no-referrer-when-downgrade", "origin", "origin-when-cross-origin",
"same-origin", "strict-origin", "strict-origin-when-cross-origin",
and "unsafe-url"
strict_transport_securitySet the value of the
Strict-Transport-Security header. See sts() for documentation of its
values
x_content_type_optionsSet the value of the
X-Content-Type-Options. Possible values are TRUE and FALSE
x_dns_prefetch_controlSet the value of the
X-DNS-Prefetch-Control. Possible values are TRUE and FALSE
x_download_optionsSet the value of the
X-Download-Options. Possible values are TRUE and FALSE
x_frame_optionsSet the value of the
X-Frame-Options. Possible values are "DENY" and "SAMEORIGIN"
x_permitted_cross_domain_policiesSet the value of the
X-Permitted-Cross-Domain-Policies. Possible values are "none",
"master-only", "by-content-type", "by-ftp-filename", "all", and
"none-this-response"
x_xss_protectionSet the value of the
X-XSS-Protection. Possible values are TRUE and FALSE
on_attach()
Method for use by fiery when attached as a plugin. Should
not be called directly.
SecurityHeaders$on_attach(app, ...)
appThe fiery server object
...Ignored
clone()
The objects of this class are cloneable with this method.
SecurityHeaders$clone(deep = FALSE)
deepWhether to make a deep clone.
# Create a plugin that turns off UI-related security headers security_headers <- SecurityHeaders$new( content_security_policy = NULL, cross_origin_embedder_policy = NULL, cross_origin_opener_policy = NULL, origin_agent_cluster = NULL, referrer_policy = NULL, x_dns_prefetch_control = NULL, x_download_options = NULL, x_frame_options = NULL, x_xss_protection = NULL ) # Use it with a fiery server app <- fiery::Fire$new() app$attach(security_headers)# Create a plugin that turns off UI-related security headers security_headers <- SecurityHeaders$new( content_security_policy = NULL, cross_origin_embedder_policy = NULL, cross_origin_opener_policy = NULL, origin_agent_cluster = NULL, referrer_policy = NULL, x_dns_prefetch_control = NULL, x_download_options = NULL, x_frame_options = NULL, x_xss_protection = NULL ) # Use it with a fiery server app <- fiery::Fire$new() app$attach(security_headers)
Strict-Transport-Security headerThis helper function exists mainly to document the possible values and prevent misspelled directives. It returns a bare list. See MDN for more information on the header
sts(max_age, include_sub_domains = NULL, preload = NULL)sts(max_age, include_sub_domains = NULL, preload = NULL)
max_age |
The maximum age the settings should be kept in the browser cache, in seconds. Recommended value is 63072000 (2 years) |
include_sub_domains |
Logical. Should subdomains be included in the policy |
preload |
Allow the settings to be cached and preloaded by a third-party,
e.g. Google or Mozilla. Can only be set if |
A bare list with the input arguments
# Default settings sts( max_age = 63072000, include_sub_domains = TRUE )# Default settings sts( max_age = 63072000, include_sub_domains = TRUE )