ExSaml.Core.Binding (ex_saml v1.0.2)

Copy Markdown View Source

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.

Summary

Functions

Unpack and parse a SAMLResponse with the given encoding.

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

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

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

Types

html_doc()

@type html_doc() :: binary()

uri()

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

xml()

@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()}

Functions

decode_response(arg1, saml_response)

@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(idp_target, signed_xml, relay_state)

@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(idp_target, signed_xml, relay_state, nonce)

@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(idp_target, signed_xml, username, relay_state)

@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(args \\ [])

(macro)

xmlDocument(record, args)

(macro)

xmlElement(args \\ [])

(macro)

xmlElement(record, args)

(macro)