# `Lather.Auth.Basic`
[🔗](https://github.com/awksedgreep/lather/blob/v1.0.49/lib/lather/auth/basic.ex#L1)

HTTP Basic authentication for SOAP services.

This module provides utilities for HTTP Basic authentication,
which can be used in HTTP headers for SOAP requests.

# `decode`

```elixir
@spec decode(String.t()) :: {:ok, {String.t(), String.t()}} | {:error, atom()}
```

Decodes an HTTP Basic authentication header.

## Parameters

  * `header_value` - The Basic authentication header value

## Examples

    iex> Lather.Auth.Basic.decode("Basic YWRtaW46cGFzc3dvcmQ=")
    {:ok, {"admin", "password"}}

    iex> Lather.Auth.Basic.decode("Invalid")
    {:error, :invalid_format}

# `header`

```elixir
@spec header(String.t(), String.t()) :: {String.t(), String.t()}
```

Creates an HTTP Basic authentication header.

## Parameters

  * `username` - The username for authentication
  * `password` - The password for authentication

## Examples

    iex> Lather.Auth.Basic.header("admin", "password")
    {"Authorization", "Basic YWRtaW46cGFzc3dvcmQ="}

# `header_value`

```elixir
@spec header_value(String.t(), String.t()) :: String.t()
```

Creates an HTTP Basic authentication header value only.

## Parameters

  * `username` - The username for authentication
  * `password` - The password for authentication

## Examples

    iex> Lather.Auth.Basic.header_value("admin", "password")
    "Basic YWRtaW46cGFzc3dvcmQ="

# `validate`

```elixir
@spec validate(String.t(), (String.t(), String.t() -&gt; boolean())) ::
  {:ok, {String.t(), String.t()}} | {:error, atom()}
```

Validates Basic authentication credentials against a validation function.

## Parameters

  * `header_value` - The Basic authentication header value
  * `validator` - A function that takes username and password and returns boolean

## Examples

    iex> validator = fn "admin", "password" -> true; _, _ -> false end
    iex> Lather.Auth.Basic.validate("Basic YWRtaW46cGFzc3dvcmQ=", validator)
    {:ok, {"admin", "password"}}

    iex> Lather.Auth.Basic.validate("Basic d3Jvbmc6d3Jvbmc=", validator)
    {:error, :invalid_credentials}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
