# `ExSaml.Core.Binding`
[🔗](https://github.com/docJerem/ex_saml/blob/main/lib/ex_saml/core/binding.ex#L1)

SAML HTTP binding handlers.

Pure Elixir port of the Erlang `esaml_binding` module.
Provides encoding/decoding of SAML messages for HTTP-Redirect and HTTP-POST bindings.

# `html_doc`

```elixir
@type html_doc() :: binary()
```

# `uri`

```elixir
@type uri() :: binary() | String.t()
```

# `xml`

```elixir
@type xml() ::
  {:xmlElement, name :: term(), expanded_name :: term(), nsinfo :: term(),
   namespace :: term(), parents :: term(), pos :: term(), attributes :: term(),
   content :: term(), language :: term(), xmlbase :: term(),
   elementdef :: term()}
  | {:xmlDocument, content :: term()}
```

# `decode_response`

```elixir
@spec decode_response(binary(), binary()) :: xml()
```

Unpack and parse a SAMLResponse with the given encoding.

When the encoding is the DEFLATE URI, the response is base64-decoded then
zlib-unzipped. For any other encoding the response is base64-decoded and an
unzip is attempted, falling back to the raw decoded data if decompression
fails. The resulting XML string is then parsed with `:xmerl_scan`.

# `encode_http_post`

```elixir
@spec encode_http_post(
  idp_target :: uri(),
  signed_xml :: xml(),
  relay_state :: binary()
) :: html_doc()
```

Encode a SAMLRequest (or SAMLResponse) as an HTTP-POST binding.

Returns an HTML document containing a form and JavaScript to auto-submit it.

# `encode_http_post`

```elixir
@spec encode_http_post(
  idp_target :: uri(),
  signed_xml :: xml(),
  relay_state :: binary(),
  nonce :: binary()
) :: html_doc()
```

Encode a SAMLRequest (or SAMLResponse) as an HTTP-POST binding with an
optional nonce for the inline script tag.

Returns an HTML document containing a form and JavaScript to auto-submit it.

# `encode_http_redirect`

```elixir
@spec encode_http_redirect(
  idp_target :: uri(),
  signed_xml :: xml(),
  username :: nil | binary(),
  relay_state :: binary()
) :: binary()
```

Encode a SAMLRequest (or SAMLResponse) as an HTTP-Redirect binding.

Returns the full redirect URI including query parameters for `SAMLEncoding`,
the payload (as `SAMLRequest` or `SAMLResponse` depending on the XML root
element), `RelayState`, and an optional `username`.

# `xmlDocument`
*macro* 

# `xmlDocument`
*macro* 

# `xmlElement`
*macro* 

# `xmlElement`
*macro* 

---

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