Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/typesend/mailgun_webhook_auth
A Plug for validating Mailgun Webhook requests in Elixir applications
https://github.com/typesend/mailgun_webhook_auth
Last synced: 8 days ago
JSON representation
A Plug for validating Mailgun Webhook requests in Elixir applications
- Host: GitHub
- URL: https://github.com/typesend/mailgun_webhook_auth
- Owner: typesend
- License: other
- Created: 2016-02-14T22:04:01.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-15T00:26:10.000Z (almost 9 years ago)
- Last Synced: 2024-10-13T13:40:04.165Z (about 1 month ago)
- Language: Elixir
- Homepage:
- Size: 5.86 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MailgunWebhookAuth
This is a Plug module for validating Mailgun Webhook requests in Elixir applications.
A 403 Unauthorized Webhook Request response is returned for all invalid requests. All other requests pass through unmodified.
## Installation
Add `mailgun_webhook_auth` to the `deps` function in your project's `mix.exs` file:
```elixir
defp deps do
[{:mailgun_webhook_auth, "~> 1.0"}]
end
```
Then run `mix do deps.get, deps.compile` inside your project's directory.## Usage
Recommended usage is within a pipeline, but it may be used within your Phoenix controllers; anywhere a Plug can be used.
It expects your private mailgun API token String to be passed at initialization.
#### Example Phoenix.Router
```elixir
pipeline :webhooks do
plug MailgunWebhookAuth,
api_token: Application.get_env(:your_application, :mailgun_key)
endscope "/webhooks", YourApplication do
pipe_through :webhooks
post "/received", WebhookController, :received
post "/delivered", WebhookController, :delivered
post "/dropped", WebhookController, :dropped
post "/bounced", WebhookController, :bounced
post "/complaints", WebhookController, :complaints
post "/unsubscribes", WebhookController, :unsubscribes
post "/clicks", WebhookController, :clicks
post "/opens", WebhookController, :opens
end```
#### Example Mix.Config
```elixir
config :your_application, mailgun_key: "key-BLAHBLAHBLAH"
```## Mailgun Documentation
See the Mailgun [Routes documentation](https://documentation.mailgun.com/user_manual.html#receiving-messages-via-http-through-a-forward-action) for more information.
## License
MailgunWebhookAuth uses the same Apache 2 license as Plug and the Elixir programming language. See the [license file](https://raw.githubusercontent.com/typesend/mailgun_webhook_auth/master/LICENSE) for more information.