Current section

Files

Jump to
potion_ingredients lib plugs security.ex
Raw

lib/plugs/security.ex

defmodule PotionIngredients.Plugs.Security do
alias Plug.Conn
def secure(conn, _opts) do
get_security_headers()
|> Enum.reduce(conn, fn {key, value}, acc ->
acc
|> Conn.put_resp_header(key, value)
end)
end
defp get_security_headers do
[
{"Strict-Transport-Security", "max-age=63072000; includeSubDomains; preload"},
{"X-XSS-Protection", "1; mode=block"},
{"X-Content-Type-Options", "nosniff"},
{"X-Frame-Options", "SAMEORIGIN"},
{"Referrer-Policy", "no-referrer-when-downgrade"},
{"Content-Security-Policy", "upgrade-insecure-requests;"}
]
end
end