ensure CSP plug config happens at runtime, not compile time

This commit is contained in:
byte[] 2020-08-06 13:27:56 -04:00
parent 3ba38edf0b
commit 5b760436a1

View file

@ -1,7 +1,11 @@
defmodule PhilomenaWeb.ContentSecurityPolicyPlug do defmodule PhilomenaWeb.ContentSecurityPolicyPlug do
alias Plug.Conn alias Plug.Conn
def init([]) do def init(opts) do
opts
end
def call(conn, _opts) do
cdn_uri = cdn_uri() cdn_uri = cdn_uri()
camo_uri = camo_uri() camo_uri = camo_uri()
@ -11,10 +15,6 @@ defmodule PhilomenaWeb.ContentSecurityPolicyPlug do
"manifest-src 'self'; img-src 'self' data: #{cdn_uri} #{camo_uri}; " <> "manifest-src 'self'; img-src 'self' data: #{cdn_uri} #{camo_uri}; " <>
"block-all-mixed-content" "block-all-mixed-content"
[csp_value: csp_value]
end
def call(conn, csp_value: csp_value) do
Conn.put_resp_header(conn, "content-security-policy", csp_value) Conn.put_resp_header(conn, "content-security-policy", csp_value)
end end