HTTP security plug: add media proxy base url host to csp
authorrinpatch <rinpatch@sdf.org>
Wed, 10 Jun 2020 17:09:16 +0000 (20:09 +0300)
committerrinpatch <rinpatch@sdf.org>
Wed, 10 Jun 2020 17:09:16 +0000 (20:09 +0300)
lib/pleroma/plugs/http_security_plug.ex

index 6a339b32ca2e2b5491f992aca5dff5317eb1fc00..620408d0fbff187dac8466da86965d877cb27ffd 100644 (file)
@@ -113,6 +113,10 @@ defmodule Pleroma.Plugs.HTTPSecurityPlug do
         add_source(acc, host)
       end)
 
+    media_proxy_base_url =
+      if Config.get([Pleroma.Upload, :base_url]),
+        do: URI.parse(Config.get([:media_proxy, :base_url])).host
+
     upload_base_url =
       if Config.get([Pleroma.Upload, :base_url]),
         do: URI.parse(Config.get([Pleroma.Upload, :base_url])).host
@@ -122,6 +126,7 @@ defmodule Pleroma.Plugs.HTTPSecurityPlug do
         do: URI.parse(Config.get([Pleroma.Uploaders.S3, :public_endpoint])).host
 
     []
+    |> add_source(media_proxy_base_url)
     |> add_source(upload_base_url)
     |> add_source(s3_endpoint)
     |> add_source(media_proxy_whitelist)