View Source Samly (samly v1.3.0)

Elixir library used to enable SAML SP SSO to a Phoenix/Plug based application.

Link to this section Summary

Functions

Returns authenticated user SAML Assertion.

Returns value of the specified attribute name in the given SAML Assertion.

Link to this section Functions

Link to this function

get_active_assertion(conn)

View Source
@spec get_active_assertion(Plug.Conn.t()) :: nil | Samly.Assertion.t()

Returns authenticated user SAML Assertion.

The struct includes the attributes sent from IdP as well as any corresponding locally computed/derived attributes. Returns nil if the current Plug session is not authenticated.

parameters

Parameters

  • conn - Plug connection

examples

Examples

# When there is an authenticated SAML assertion
%Assertion{} = Samly.get_active_assertion()
Link to this function

get_attribute(assertion, name)

View Source

Returns value of the specified attribute name in the given SAML Assertion.

Checks for the attribute in computed map first and attributes map next. Returns a UTF-8 binary or a list of UTF-8 binaries (in case of multi-valued) if the given attribute is present. Returns nil if attribute is not present.

parameters

Parameters

examples

Examples

assertion = Samly.get_active_assertion()
# returns a list if the attribute is multi-valued
roles = Samly.get_attribute(assertion, "roles")
computed_fullname = Samly.get_attribute(assertion, "fullname")