@@ -22,7 +22,7 @@ defmodule Samly do
2222 # When there is an authenticated SAML assertion
2323 %Assertion{} = Samly.get_active_assertion()
2424 """
25- @ spec get_active_assertion ( Conn . t ( ) ) :: Assertion . t ( ) | nil
25+ @ spec get_active_assertion ( Conn . t ( ) ) :: nil | Assertion . t ( )
2626 def get_active_assertion ( conn ) do
2727 case Conn . get_session ( conn , "samly_assertion_key" ) do
2828 { _idp_id , _nameid } = assertion_key ->
@@ -37,7 +37,8 @@ defmodule Samly do
3737 Returns value of the specified attribute name in the given SAML Assertion.
3838
3939 Checks for the attribute in `computed` map first and `attributes` map next.
40- Returns `nil` if attribute is not present.
40+ Returns a UTF-8 binary or a list of UTF-8 binaries (in case of multi-valued)
41+ if the given attribute is present. Returns `nil` if attribute is not present.
4142
4243 ## Parameters
4344
@@ -47,14 +48,15 @@ defmodule Samly do
4748 ## Examples
4849
4950 assertion = Samly.get_active_assertion()
51+ # returns a list if the attribute is multi-valued
52+ roles = Samly.get_attribute(assertion, "roles")
5053 computed_fullname = Samly.get_attribute(assertion, "fullname")
5154 """
52- @ spec get_attribute ( nil | Assertion . t ( ) , String . t ( ) ) :: nil | String . t ( )
55+ @ spec get_attribute ( nil | Assertion . t ( ) , Assertion . attr_name_t ( ) ) ::
56+ nil | Assertion . attr_value_t ( )
5357 def get_attribute ( nil , _name ) , do: nil
5458
5559 def get_attribute ( % Assertion { } = assertion , name ) do
56- computed = assertion . computed
57- attributes = assertion . attributes
58- Map . get ( computed , name ) || Map . get ( attributes , name )
60+ Map . get ( assertion . computed , name ) || Map . get ( assertion . attributes , name )
5961 end
6062end
0 commit comments