diff options
author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2019-02-02 19:06:26 +0100 |
---|---|---|
committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2019-02-12 22:12:12 +0100 |
commit | da4c662af31a2c45c767f2a9ed136272ee9fc2c8 (patch) | |
tree | a7bcf49690e6871599d3f26c0448a206359263e0 /lib | |
parent | 00e8f0b07dd3dced84b0317e1c5c4156d249dec4 (diff) | |
download | pleroma-da4c662af31a2c45c767f2a9ed136272ee9fc2c8.tar.gz |
Plugs.HTTPSecurityPlug: Add webpacker to connect-src
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/plugs/http_security_plug.ex | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/pleroma/plugs/http_security_plug.ex b/lib/pleroma/plugs/http_security_plug.ex index 05e935f2c..057553e24 100644 --- a/lib/pleroma/plugs/http_security_plug.ex +++ b/lib/pleroma/plugs/http_security_plug.ex @@ -34,6 +34,21 @@ defmodule Pleroma.Plugs.HTTPSecurityPlug do defp csp_string do scheme = Config.get([Pleroma.Web.Endpoint, :url])[:scheme] + websocket_url = String.replace(Pleroma.Web.Endpoint.static_url(), "http", "ws") + + connect_src = + if Mix.env() == :dev do + "connect-src 'self' http://localhost:3035/ " <> websocket_url + else + "connect-src 'self' " <> websocket_url + end + + script_src = + if Mix.env() == :dev do + "script-src 'self' 'unsafe-eval'" + else + "script-src 'self'" + end [ "default-src 'none'", @@ -43,11 +58,9 @@ defmodule Pleroma.Plugs.HTTPSecurityPlug do "media-src 'self' https:", "style-src 'self' 'unsafe-inline'", "font-src 'self'", - "connect-src 'self' " <> String.replace(Pleroma.Web.Endpoint.static_url(), "http", "ws"), "manifest-src 'self'", - if Mix.env() == :dev do - "script-src 'self' 'unsafe-eval'" - end, + connect_src, + script_src, if scheme == "https" do "upgrade-insecure-requests" end |