mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
middleware: Implement middleware for common headers such as CSP
- This allows overriding these headers in individual pages easily instead of relaxing global policy. - Drop the obsolete CSP directive "block-all-mixed-content" and avoid a console warning in Firefox. Tests: - Load a page and notice in the browser developer tools that the three headers referrer-policy, content-security-policy, and x-content-type-options are set as before. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
3eef1d9324
commit
2467d6a033
3 files changed
+91
-42
No files matched your search
@@ -47,48 +47,6 @@
|
||||
RedirectMatch "^/$" "/plinth"
|
||||
</IfFile>
|
||||
|
||||
##
|
||||
## Disable sending Referer (sic) header from FreedomBox web interface to
|
||||
## external websites. This improves privacy by not disclosing FreedomBox
|
||||
## domains/URLs to external domains. Apps such as blogs which want to popularize
|
||||
## themselves with referrer header may still do so.
|
||||
##
|
||||
## A strict Content Security Policy.
|
||||
## - @fonts are allowed only from FreedomBox itself.
|
||||
## - <frame>/<iframe> sources are disabled.
|
||||
## - <img> sources are allowed only from FreedomBox itself.
|
||||
## - Manifest file is not allowed as there is none yet.
|
||||
## - <audio>, <video>, <track> tags are not allowed yet.
|
||||
## - <object>, <embed>, <applet> tags are not allowed yet.
|
||||
## - Allow JS from FreedomBox itself (no inline and attribute scripts).
|
||||
## - Allow inline CSS and CSS files from Freedombox itself.
|
||||
## - Web worker sources are allowed only from FreedomBox itself (for JSXC).
|
||||
## - All other fetch sources including Ajax are not allowed from FreedomBox
|
||||
## itself.
|
||||
## - <base> tag is not allowed.
|
||||
## - No plugins types are alllowed since object-src is 'none'.
|
||||
## - Form action should be to FreedomBox itself.
|
||||
## - This interface may be not embedded in <frame>, <iframe>, etc. tags.
|
||||
## - When serving HTTPS, don't allow HTTP assets.
|
||||
##
|
||||
## Enable strict sandboxing enabled with some exceptions:
|
||||
## - Allow running Javascript.
|
||||
## - Allow popups as sometimes we use <a target=_blank>
|
||||
## - Allow popups to have different sandbox requirements as we launch apps' web
|
||||
## clients.
|
||||
## - Allow forms to support configuration forms.
|
||||
## - Allow policies to treat same origin differently from other origins
|
||||
## - Allow downloads such as backup tarballs.
|
||||
##
|
||||
## Disable browser guessing of MIME types. FreedoBox already sets good content
|
||||
## types for all the common file types.
|
||||
##
|
||||
<LocationMatch "^/(plinth|freedombox)">
|
||||
Header set Referrer-Policy 'same-origin'
|
||||
Header set Content-Security-Policy "font-src 'self'; frame-src 'none'; img-src 'self' data:; manifest-src 'none'; media-src 'none'; object-src 'none'; script-src 'self'; style-src 'self'; worker-src 'self'; default-src 'self'; base-uri 'none'; sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms allow-same-origin allow-downloads; form-action 'self'; frame-ancestors 'none'; block-all-mixed-content;"
|
||||
Header set X-Content-Type-Options 'nosniff'
|
||||
</LocationMatch>
|
||||
|
||||
##
|
||||
## On all sites, provide FreedomBox on a default path: /plinth
|
||||
##
|
||||
|
||||
Reference in new issue
Block a user