Boruta.BasicAuth (Boruta core v0.2.1) View Source

HTTP BasicAuth utilities

Provide utilities to decode Basic authorization header as stated in RFC 7617 - The 'Basic' HTTP Authentication Scheme

Link to this section Summary

Functions

Decode given authorization header and returns an array containing username and password.

Link to this section Functions

Specs

decode(authorization_header :: String.t()) ::
  {:ok, [String.t()]} | {:error, String.t()}

Decode given authorization header and returns an array containing username and password.

Examples

iex> Boruta.BasicAuth.decode("Basic dXNlcm5hbWU6cGFzc3dvcmQ=")
{:ok, ["username", "password"]}

iex> Boruta.BasicAuth.decode("bad_authorization_header")
{:error, "`bad_authorization_header` is not a valid Basic authorization header."}