View Source Smee (Smee v0.5.0)

Smee is a pragmatic library for handling SAML metadata with Elixir, Erlang or any other BEAM language.

Features

  • Download remote SAML metadata or load local files, with effective caching
  • Manage and compare metadata files and individual entity metadata
  • MDQ API (which can also emulate MDQ style lookups with aggregate files)
  • A focus on streaming with reliable and surprisingly low memory usage
  • Filter entity streams by various criteria
  • Validate XML signatures, automatically download and confirm signing certificates
  • Transform metadata using XSLT, or extract data
  • Access XML using Erlang's Xmerl library (sweetened by SweetXML)
  • Recombine entity streams into aggregates or other data formats
  • Can be used with applications or in simple .exs scripts

Modules

The top level Smee module contains a few simplified, top level functions better suited to simpler scripts. Other modules in Smee contain more tools for handling SAML metadata, such as:

Summary

Functions

Lists the IDs of every entity in the metadata.

Downloads a source of metadata (local or remote) and returns a %Metadata{} struct containing XML and information.

Retrieves information for a single entity from an MDQ service (real or emulated) and returns an %Entity{} struct.

Defines a source of metadata

Defines a source of metadata

Streams all entities in the specified metadata or source.

Functions

@spec entity_ids(source :: Smee.Source.t() | Smee.Metadata.t()) :: [binary()]

Lists the IDs of every entity in the metadata.

This version of the function can accept either a %Source{} or a %Metadata{} struct containing already-loaded Metadata.

Example

iex> Smee.source("http://metadata.ukfederation.org.uk/ukfederation-metadata.xml")
iex> |> Smee.entity_ids()
@spec fetch!(source :: Smee.Source.t()) :: Smee.Metadata.t()

Downloads a source of metadata (local or remote) and returns a %Metadata{} struct containing XML and information.

Example

iex> "http://metadata.ukfederation.org.uk/ukfederation-metadata.xml"
iex> |> Smee.source()
iex> |> Smee.fetch!()
Link to this function

lookup!(source, entity_id)

View Source
@spec lookup!(source :: Smee.Source.t() | Smee.Metadata.t(), entity_id :: binary()) ::
  Smee.Entity.t()

Retrieves information for a single entity from an MDQ service (real or emulated) and returns an %Entity{} struct.

This version of the function can accept either a %Source{} or a %Metadata{} struct containing already-loaded Metadata.

Example

iex> "http://mdq.ukfederation.org.uk/"
iex> |> Smee.source(type: :mdq)
iex> |> Smee.lookup!("https://cern.ch/login")

iex> "http://metadata.ukfederation.org.uk/ukfederation-metadata.xml"
iex> |> Smee.source(type: :aggregate)
iex> |> Smee.lookup!("https://cern.ch/login")
@spec source(url :: binary()) :: Smee.Source.t()

Defines a source of metadata

Sources of metadata include online aggregate XML, local aggregate files, individual entities, and MDQ services. This function will only define sources of aggregate XML.

Example

iex> Smee.source("http://metadata.ukfederation.org.uk/ukfederation-metadata.xml")
iex>
@spec source(url :: binary(), options :: keyword()) :: Smee.Source.t()

Defines a source of metadata

Sources of metadata include online aggregate XML, local aggregate files, individual entities, and MDQ services. This function allows a lot of customisation, particularly the type. Types are:

  • :aggregate (a file containing a collection of entityDescriptor fragments inside a entitiesDescriptor tag, as used by federations)
  • :single (a file with a single entityDescriptor, as used for individual metadata records)
  • :mdq (an online MDQ service)

URLs may be remote (http:// and https://) or local (file://). Local files can be specified as bare paths.

See Smee.Source.new for full details

Example

iex> Smee.source("http://mdq.ukfederation.org.uk/", type: :mdq, retries: 1, label: "UK MDQ Service")
iex> Smee.source("support/static/valid.xml", type: :single, retries: 1, label: "My IdP")
@spec stream_entities(source :: Smee.Source.t() | Smee.Metadata.t()) :: Enumerable.t()

Streams all entities in the specified metadata or source.

This version of the function can accept either a %Source{} or a %Metadata{} struct containing already-loaded Metadata.

Example

iex> Smee.stream_entities("http://metadata.ukfederation.org.uk/ukfederation-metadata.xml")
iex> |> Stream.take(1)
iex> |> Enum.to_list