PlugHmacAuth v0.1.0 PlugHmacAuth View Source

PlugHmacAuth provides a Plug for HMAC authentication.

Link to this section Summary

Functions

Callback implementation for Plug.call/2.

Returns the first token from http request header by specific key.

Returns signatre generated by payload and secret key.

Callback implementation for Plug.init/1.

Link to this section Types

Specs

opts() :: [
  key_access_id: String.t(),
  key_signature: String.t(),
  hmac_hash_algo:
    :md4
    | :md5
    | :sha
    | :sha224
    | :sha256
    | :sha384
    | :sha3_224
    | :sha3_256
    | :sha3_384
    | :sha3_512
    | :sha512,
  secret_handler: module(),
  error_handler: module()
]

Link to this section Functions

Specs

Callback implementation for Plug.call/2.

Link to this function

fetch_token_from_header(conn, key)

View Source

Specs

fetch_token_from_header(Plug.Conn.t(), binary()) ::
  {:error, :invalid_key} | {:ok, binary()}

Returns the first token from http request header by specific key.

Link to this function

gen_signature(payload, secret_key, hmac_hash_algo)

View Source

Specs

gen_signature(String.t(), String.t(), atom()) :: String.t()

Returns signatre generated by payload and secret key.

Specs

get_payload(Plug.Conn.t()) :: String.t()

Specs

init(opts :: Keyword.t()) :: Keyword.t()

Callback implementation for Plug.init/1.

Link to this function

verify_payload(conn, secret_key, access_signature, hmac_hash_algo)

View Source

Specs

verify_payload(
  Plug.Conn.t(),
  String.t(),
  String.t(),
  :md4
  | :md5
  | :sha
  | :sha224
  | :sha256
  | :sha384
  | :sha3_224
  | :sha3_256
  | :sha3_384
  | :sha3_512
  | :sha512
) :: :ok | {:error, :invalid_signature}