-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Will Ceolin
committed
Jul 21, 2024
1 parent
729a498
commit a14abe2
Showing
27 changed files
with
184 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
defmodule ZoonkWeb.Plugs.ContentSecurityPolicy do | ||
@moduledoc """ | ||
Set a CSP nonce for the current request. | ||
""" | ||
|
||
@spec init(Keyword.t()) :: Keyword.t() | ||
def init(options), do: options | ||
|
||
@spec call(Plug.Conn.t(), Keyword.t()) :: Plug.Conn.t() | ||
def call(conn, opts) do | ||
nonce = Keyword.get(opts, :nonce) | ||
Plug.Conn.assign(conn, :csp_nonce, nonce) | ||
end | ||
|
||
@doc """ | ||
Get allowed connect-src domains. | ||
## Examples | ||
iex> ZoonkWeb.Plugs.CspNonce.get_connect_src() | ||
"https://fly.storage.tigris.dev" | ||
""" | ||
@spec get_connect_src() :: String.t() | ||
def get_connect_src, do: Application.get_env(:zoonk, :csp)[:connect_src] | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.