Skip to content

Commit b64d78f

Browse files
Add iframe security headers (#1323)
1 parent d51155d commit b64d78f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Diff for: apps/api/lib/api_web/endpoint.ex

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ defmodule ApiWeb.Endpoint do
4343
plug Plug.MethodOverride
4444
plug Plug.Head
4545
plug ApiWeb.Plugs.MetricsExporter
46+
plug ApiWeb.Plugs.SecureHeaders
4647

4748
# The session will be stored in the cookie and signed,
4849
# this means its contents can be read but not tampered with.

Diff for: apps/api/lib/api_web/plugs/secure_headers.ex

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
defmodule ApiWeb.Plugs.SecureHeaders do
2+
import Plug.Conn
3+
4+
def init(opts), do: opts
5+
6+
def call(conn, _opts) do
7+
conn
8+
|> put_resp_header("x-frame-options", "ALLOW-FROM #{Core.url("/")}")
9+
|> put_resp_header("content-security-policy", "frame-ancestors #{Core.url("/")};")
10+
end
11+
end

0 commit comments

Comments
 (0)