As promised, this feature was just enabled by default: CSP Frame Ancestors enabled by default
Hello,
I am currently setting up Google Adsense on my website and seems I am missing the āEnable CSP violation report collection at /csp_reportsā settingsā¦ I am currently self-hosting Discourse on version 2.9.0.beta6
above, in quote, a screenshot of the setting I am missing
above, my setting page for CSP with the āEnable CSP violation report collection at /csp_reportsā missing.
Any help is appreciated ! And please tell me if I set-up the settings I have correctly for Adsense, I never used it before !
Apologies, my earlier replies here are outdated because as of ~ a month ago we made content_security_policy_collect_reports
a hidden setting. You can still enable it but you need to do it via the Rails console, as in:
./launcher enter app
...
rails c
...
SiteSetting.content_security_policy_collect_reports = true
Note that this is very noisy, I highly recommend not going down this route at all and simply enabling CSP and navigating the site with the browser console open using multiple browsers (Chrome, Firefox, Safari). Youāll find most issues that way. And with the configuration you have, youāre basically allowing almost all that CSP protects against anyway, so you shouldnāt have any need for the reports.
Maybe I am missing something, but I do not see these settings in the settings UI.
content_security_policy
content_security_policy_report_only
-
content_security_policy_collect_reports
(I see that is hidden now) content_security_policy_script_src
Are these options available to hosted instances? I didnāt see any mention of that being a limitation in the original post or comments.
Edit: Also attempted to set the security policy through a theme.
Does not seem to be working as instructed in original post.
Iām assuming the hosted plan Iām on doesnāt allow this, even when done via a theme or theme component?
Or maybe I am just doing something totally wrong.
Currently, Discourse ships a CSP Level 2 policy with the following directives by default:
base-uri
restricts the URLs for<base>
element
Is there any option to override the default value for the base-uri
header?
Where are <base>
elements actually used in discourse?
Would that break Discourse push notifications?
Could be. Might need a more suitable setting.
A post was split to a new topic: Whatās the suggested method to use secure images?
Hi there,
May I know how to bypass the issue below? I have added the script invoking a new Function() expression into content_security_policy_script_src, but my browser console still complains below error. Where I can exclude the unsafe-eval? Thanks!
Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive:
Apologies. Please ignore my previous post if my below remarks are correct. Just know through above posts I can set āunsafe-evalā directly to content_security_policy_script_src, and thereās no JS error reported in console any more.
Maybe have a look at the content security policy script src
site setting?
Yes. As said in previous replies āunsafe-evalā can be added directly to content_security_policy_script_src, I thought only URL base or full URL allowed to add.