DevSpaceAuth is a wrapper around Plug.BasicAuth with rate limiting.
It is designed to protect endpoints that are used only by developers.
Add dev_space_auth to your list of dependencies in mix.exs:
def deps do
[
{:dev_space_auth, github: "prosapient/dev_space_auth"}
]
end- Define a rate limiter module in your app:
defmodule MyApp.RateLimit do
use Hammer, backend: :ets
end- Add it to your supervision tree (before the endpoint):
children = [
MyApp.RateLimit,
MyAppWeb.Endpoint
]- Use the plug with the
rate_limiteroption:
pipeline :dev_space_auth do
plug DevSpaceAuth, rate_limiter: MyApp.RateLimit
end- Configure credentials:
config :dev_space_auth,
username: "username",
password: "password"