DevL / plug_require_header

An Elixir Plug for requiring and extracting a given header.
MIT License
27 stars 3 forks source link

Allow to set required header values #6

Open sobolevn opened 5 years ago

sobolevn commented 5 years ago

My use-case is pretty simple: I want to use webhooks with a secret key. Both parties know this value.

And currently I write this code:

plug PlugRequireHeader, headers: [auth_token: "X-Gitlab-Token"]
plug :verify_auth_token

And then I actually verify it.

So, my proposal is to allow something like:

plug PlugRequireHeader, headers: [auth_token: %{"X-Gitlab-Token" => System.get_env("SECRET_KEY")}]