From 5b760436a1f4790ca84478043bb77379d3162909 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Thu, 6 Aug 2020 13:27:56 -0400 Subject: [PATCH] ensure CSP plug config happens at runtime, not compile time --- .../plugs/content_security_policy_plug.ex | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/philomena_web/plugs/content_security_policy_plug.ex b/lib/philomena_web/plugs/content_security_policy_plug.ex index 7fe0835b..ab26e399 100644 --- a/lib/philomena_web/plugs/content_security_policy_plug.ex +++ b/lib/philomena_web/plugs/content_security_policy_plug.ex @@ -1,7 +1,11 @@ defmodule PhilomenaWeb.ContentSecurityPolicyPlug do alias Plug.Conn - def init([]) do + def init(opts) do + opts + end + + def call(conn, _opts) do cdn_uri = cdn_uri() camo_uri = camo_uri() @@ -11,10 +15,6 @@ defmodule PhilomenaWeb.ContentSecurityPolicyPlug do "manifest-src 'self'; img-src 'self' data: #{cdn_uri} #{camo_uri}; " <> "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) end