View Source SmeeView.RequestedAttributes (SmeeView v0.2.1)

This module can extracts the <RequestedAttribute> elements in entity metadata as "aspect" structs, and then process and filter the results.

Aspects can be extracted with three functions:

  • Views, via view/3 are lists of aspects
  • Prisms, via prism/3 are maps of entity IDs to views
  • There is also view_one/3 which returns the first aspect found

Aspects can be extracted from Smee.Metadata structs, Smee.Entity structs, or lists of aspects, Metadata and Entity structs.

The other functions in this module are intended to be applied to collections of aspect structs - for working with individual aspects, please look at the appropriate Aspect module.

Summary

Functions

Returns true if the aspects contain the specified attribute name

Returns true if the aspects contain the specified attribute friendly name

Returns a list of all attribute names (full, technical, URI names).

Removes any non-IdP aspects from a list (view) or map (prism)

Returns a list of all attribute names (full, technical, URI names).

Returns only optional attributes

Returns a map of Elixir.SmeeView.Aspects.RequestedAttribute aspect structs extracted from the input data, with entity IDs as keys.

Returns only required attributes

Returns only SAML1 attributes

Returns only SAML2 attributes

Removes any non-SP aspects from a list (view) or map (prism)

Returns a list of Elixir.SmeeView.Aspects.RequestedAttribute aspect structs extracted from the input data.

Returns a single Elixir.SmeeView.Aspects.RequestedAttribute aspect struct extracted from one record in the input data.

Functions

@spec contain?(aspects :: list() | map(), name :: binary()) :: boolean() | map()

Returns true if the aspects contain the specified attribute name

  RequestedAttributes.contain?(attrs, "urn:oid:1.3.6.1.4.1.5923.1.1.1.6")
# => true

Link to this function

contain_friendly?(aspects, friendly_name)

View Source
@spec contain_friendly?(aspects :: list() | map(), name :: binary()) ::
  boolean() | map()

Returns true if the aspects contain the specified attribute friendly name

  RequestedAttributes.contain?(attrs, "sn")
# => true

@spec friendly_names(aspects :: list() | map()) :: list() | map()

Returns a list of all attribute names (full, technical, URI names).

The results are sorted and each value is unique.

  RequestedAttributes.friendly_names(attrs)
# => ["eduPersonPrincipalName", "email", "organizationName"]
@spec idp_filter(aspects :: map() | list()) :: map() | list()

Removes any non-IdP aspects from a list (view) or map (prism)

RequestedAttributes.idp_filter(view)
# => []
@spec names(aspects :: list() | map()) :: list() | map()

Returns a list of all attribute names (full, technical, URI names).

The results are sorted and each value is unique.

  RequestedAttributes.names(attrs)
# => ["urn:oid:1.3.6.1.4.1.5923.1.1.1.6", "urn:oid:0.9.2342.19200300.100.1.3", "urn:oid:2.5.4.10"]
@spec optional_filter(aspects :: list() | map()) :: list()

Returns only optional attributes

Filters the view (list) or prism (map) to only include required attributes

SmeeView.RequestedAttributes.optional_filter(aspects)
# =>  [%SmeeView.Aspect.RequestedAttribute{}, %SmeeView.Aspect.RequestedAttribute{}]
Link to this function

prism(various, role \\ :all, options \\ [])

View Source
@spec prism(
  various :: Smee.Entity.t() | Smee.Metadata.t() | list(),
  role :: atom(),
  options :: keyword()
) :: map()

Returns a map of Elixir.SmeeView.Aspects.RequestedAttribute aspect structs extracted from the input data, with entity IDs as keys.

Input data can be a Smee.Entity or Smee.Metadata struct, or a list containing Smee.Entity and/or Smee.Metadata structs. Only appropriate aspect records will be returned.

prism/3 is useful for extracting specific types of aspects from lists of entity records, or metadata. If you are only interested in one aspect from a single Smee.Entity struct then you should probably use view/3 instead.

The optional role parameter will optimize the results to only search for either :idp or :sp aspects. The default is :all.

RequestedAttributes.prism(entity)
# => %{"https://example.com/shibboleth" =>  [%Elixir.SmeeView.Aspects.RequestedAttribute{}, %Elixir.SmeeView.Aspects.RequestedAttribute{},]}
@spec required_filter(aspects :: list() | map()) :: list()

Returns only required attributes

Filters the view (list) or prism (map) to only include required attributes

SmeeView.RequestedAttributes.required_filter(aspects)
# =>  [%SmeeView.Aspect.RequestedAttribute{}, %SmeeView.Aspect.RequestedAttribute{}]
@spec saml1_filter(aspects :: list() | map()) :: list()

Returns only SAML1 attributes

Filters the view (list) or prism (map) to only include SAML1 attributes

RequestedAttributes.saml1_filter(aspects)
# =>  [%Elixir.SmeeView.Aspects.RequestedAttribute{}]
@spec saml2_filter(aspects :: list() | map()) :: list()

Returns only SAML2 attributes

Filters the view (list) or prism (map) to only include SAML2 attributes

RequestedAttributes.saml2_filter(aspects)
# => [%Elixir.SmeeView.Aspects.RequestedAttribute{}]
@spec sp_filter(aspects :: map() | list()) :: map() | list()

Removes any non-SP aspects from a list (view) or map (prism)

RequestedAttributes.sp_filter(view)
# => []
Link to this function

view(list, role \\ :all, options \\ [])

View Source
@spec view(
  list :: Smee.Entity.t() | Smee.Metadata.t() | list(),
  role :: atom(),
  options :: keyword()
) ::
  list()

Returns a list of Elixir.SmeeView.Aspects.RequestedAttribute aspect structs extracted from the input data.

Input data can be a Smee.Entity or Smee.Metadata struct, or a list containing Smee.Entity, Smee.Metadata or any aspects. Only appropriate aspect records will be returned.

view/3 is useful for extracting specific types of aspects from one Entity, but because it has no entity ID information it's often not the best choice for handling Metadata. When extracting information from entire metadata it's often better to use prism/3 which returns the same data in a map, associated with each entity's ID.

The optional role parameter will optimize the results to only search for either :idp or :sp aspects. The default is :all.

RequestedAttributes.view(entity)
# => [%Elixir.SmeeView.Aspects.RequestedAttribute{}, %Elixir.SmeeView.Aspects.RequestedAttribute{}]
Link to this function

view_one(smee_data, role \\ :all, options \\ [])

View Source
@spec view_one(
  list :: Smee.Entity.t() | Smee.Metadata.t() | list(),
  role :: atom(),
  options :: keyword()
) :: SmeeView.Aspects.RequestedAttribute.t() | nil

Returns a single Elixir.SmeeView.Aspects.RequestedAttribute aspect struct extracted from one record in the input data.

Input data can be a Smee.Entity or Smee.Metadata struct, or a list containing Smee.Entity, Smee.Metadata or any aspects.

Only one entity will be processed and then only one aspect will be returned. If you pass one Entity struct as the input, it will be that entity (obviously). If you pass metadata structs or lists one entity will be chosen at random. The first suitable entity will be returned.

view_one/3 is intended for use with a single entity record and aspects like SmeeView.Aspect.Entity, SmeeView.Aspect.SP' orSmeeView.Aspect.Organization' but will work with any aspect.

The optional role parameter will optimize the results to only search for either :idp or :sp aspects. The default is :all.

RequestedAttributes.view_one(entity)
# => %Elixir.SmeeView.Aspects.RequestedAttribute{}