# `ExSaml.SPHandler`
[🔗](https://github.com/docJerem/ex_saml/blob/main/lib/ex_saml/sp_handler.ex#L1)

Handles Service Provider SAML responses: metadata generation, assertion consumption,
and logout handling.

## Functions

  * `send_metadata/1` - Returns SP metadata XML for the given IdP
  * `consume_signin_response/2` - Processes the IdP sign-in response and returns the assertion
  * `handle_logout_response/1` - Processes the IdP logout response
  * `handle_logout_request/1` - Processes an IdP-initiated logout request

# `consume_signin_response`

Processes the IdP sign-in response and extracts the SAML assertion.

Returns `{:ok, %{assertion: assertion, nonce: nonce, user_token: token, redirect_uri: uri}}`
on success, or `{:error, reason}` on failure.

# `consume_signin_response`

# `handle_logout_request`

Handles an IdP-initiated logout request.

# `handle_logout_response`

Processes the IdP logout response and redirects to the target URL.

# `send_metadata`

Returns the SP metadata XML for the IdP in `conn.private[:ex_saml_idp]`.

# `target_url`

Returns the fallback target URL from application config (defaults to `"/"`).

# `target_url`

Returns the target URL from session or relay state cache.

---

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