Boruta core v0.1.0-rc.5 Boruta.BasicAuth 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

Link to this function

decode(string)

View Source
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."}