Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iframe security headers #1323

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/api/lib/api_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ defmodule ApiWeb.Endpoint do
plug Plug.MethodOverride
plug Plug.Head
plug ApiWeb.Plugs.MetricsExporter
plug ApiWeb.Plugs.SecureHeaders

# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
Expand Down
11 changes: 11 additions & 0 deletions apps/api/lib/api_web/plugs/secure_headers.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
defmodule ApiWeb.Plugs.SecureHeaders do
import Plug.Conn

def init(opts), do: opts

def call(conn, _opts) do
conn
|> put_resp_header("x-frame-options", "ALLOW-FROM #{Core.url("/")}")
|> put_resp_header("content-security-policy", "frame-ancestors #{Core.url("/")};")
end
end
Loading