From db3829c96841c65938de2fa1342a50ca0cb19c5f Mon Sep 17 00:00:00 2001 From: Fumiaki Kinoshita Date: Mon, 5 Aug 2024 19:46:33 +0900 Subject: [PATCH] Separate multiple attribute values with the same name instead of concatenating them (#67) --- CHANGELOG.md | 1 + src/Network/Wai/SAML2/Assertion.hs | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba23eb3..79b34ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.7 - Replaced `x509Certificate` with `x509Certificates` in `IDPSSODescriptor` so that it may have more than one certificate ([#65](https://github.com/mbg/wai-saml2/pull/65) by [@fumieval](https://github.com/fumieval)) +- Added `attributeValues` to `AssertionAttribute` in order to handle multiple attribute values with the same name ([#67](https://github.com/mbg/wai-saml2/pull/67) by [@fumieval](https://github.com/fumieval)) ## 0.6 diff --git a/src/Network/Wai/SAML2/Assertion.hs b/src/Network/Wai/SAML2/Assertion.hs index 3d137c6..f4b7f87 100644 --- a/src/Network/Wai/SAML2/Assertion.hs +++ b/src/Network/Wai/SAML2/Assertion.hs @@ -230,19 +230,24 @@ data AssertionAttribute = AssertionAttribute { attributeFriendlyName :: !(Maybe T.Text), -- | The name format. attributeNameFormat :: !T.Text, - -- | The value of the attribute. - attributeValue :: !T.Text + -- | The value of the attribute, concatened from the 'attributeValues'. + attributeValue :: !T.Text, + -- | The values of the attribute. + -- + -- @since 0.7 + attributeValues :: ![T.Text] } deriving (Eq, Show) instance FromXML AssertionAttribute where parseXML cursor = do + let attributeValues = cursor $/ element (saml2Name "AttributeValue") &/ content pure AssertionAttribute{ attributeName = T.concat $ attribute "Name" cursor, attributeFriendlyName = toMaybeText $ attribute "FriendlyName" cursor, attributeNameFormat = T.concat $ attribute "NameFormat" cursor, - attributeValue = T.concat $ - cursor $/ element (saml2Name "AttributeValue") &/ content + attributeValue = T.concat attributeValues, + attributeValues = attributeValues } -- | SAML2 assertion statements (collections of assertion attributes).