forked from dropbox/esaml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Always return attribute values as lists
BREAKING CHANGE
- Loading branch information
Showing
1 changed file
with
5 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -292,15 +292,11 @@ decode_assertion_attributes(Xml) -> | |
case [X#xmlAttribute.value || X <- AttrElem#xmlElement.attributes, X#xmlAttribute.name =:= 'Name'] of | ||
[Name] -> | ||
case xmerl_xpath:string("saml:AttributeValue/text()", AttrElem, [{namespace, Ns}]) of | ||
[#xmlText{value = Value}] -> | ||
[{common_attrib_map(Name), Value} | [{Name, Value} | In]]; | ||
[] -> | ||
In; | ||
List -> | ||
if (length(List) > 0) -> | ||
Value = [X#xmlText.value || X <- List, element(1, X) =:= xmlText], | ||
[{common_attrib_map(Name), Value} | [{Name, Value} | In]]; | ||
true -> | ||
In | ||
end | ||
Value = [X#xmlText.value || X <- List, element(1, X) =:= xmlText], | ||
[{common_attrib_map(Name), Value} | [{Name, Value} | In]] | ||
end; | ||
_ -> In | ||
end | ||
|
@@ -660,7 +656,7 @@ decode_attributes_test() -> | |
{Doc, _} = xmerl_scan:string("<saml:Assertion xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\" Version=\"2.0\" IssueInstant=\"test\"><saml:Subject><saml:NameID>foobar</saml:NameID><saml:SubjectConfirmation Method=\"urn:oasis:names:tc:SAML:2.0:cm:bearer\"><saml:SubjectConfirmationData Recipient=\"foobar123\" /></saml:SubjectConfirmation></saml:Subject><saml:AttributeStatement><saml:Attribute Name=\"urn:oid:0.9.2342.19200300.100.1.3\"><saml:AttributeValue>[email protected]</saml:AttributeValue></saml:Attribute><saml:Attribute Name=\"foo\"><saml:AttributeValue>george</saml:AttributeValue><saml:AttributeValue>bar</saml:AttributeValue></saml:Attribute><saml:Attribute Name=\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress\"><saml:AttributeValue>[email protected]</saml:AttributeValue></saml:Attribute></saml:AttributeStatement></saml:Assertion>", [{namespace_conformant, true}]), | ||
Assertion = decode_assertion(Doc), | ||
{ok, #esaml_assertion{attributes = Attrs}} = Assertion, | ||
[{emailaddress, "[email protected]"}, {foo, ["george", "bar"]}, {mail, "[email protected]"}, {"foo",["george","bar"]}, {"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", "[email protected]"}, {"urn:oid:0.9.2342.19200300.100.1.3", "[email protected]"}] = lists:sort(Attrs). | ||
[{emailaddress, ["[email protected]"]}, {foo, ["george", "bar"]}, {mail, ["[email protected]"]}, {"foo",["george","bar"]}, {"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", ["[email protected]"]}, {"urn:oid:0.9.2342.19200300.100.1.3", ["[email protected]"]}] = lists:sort(Attrs). | ||
|
||
decode_solicited_in_response_to_test() -> | ||
{Doc, _} = xmerl_scan:string("<samlp:Response xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\" Version=\"2.0\" IssueInstant=\"2013-01-01T01:01:01Z\"><saml:Issuer>foo</saml:Issuer><samlp:Status><samlp:StatusCode Value=\"urn:oasis:names:tc:SAML:2.0:status:Success\" /></samlp:Status><saml:Assertion Version=\"2.0\" IssueInstant=\"test\"><saml:Issuer>foo</saml:Issuer><saml:Subject><saml:NameID>foobar</saml:NameID><saml:SubjectConfirmation Method=\"urn:oasis:names:tc:SAML:2.0:cm:bearer\"><saml:SubjectConfirmationData Recipient=\"foobar123\" InResponseTo=\"_1234567890\" /></saml:SubjectConfirmation></saml:Subject><saml:Conditions NotBefore=\"before\" NotOnOrAfter=\"notafter\"><saml:AudienceRestriction><saml:Audience>foobaraudience</saml:Audience></saml:AudienceRestriction></saml:Conditions></saml:Assertion></samlp:Response>", [{namespace_conformant, true}]), | ||
|