flipboxfactory / saml-sp

SAML Service Provider (SP) Plugin for Craft CMS
https://saml-sp.flipboxfactory.com/
Other
19 stars 5 forks source link

User.php construct fails on only one attribute #54

Closed rrrmity closed 4 years ago

rrrmity commented 4 years ago

We receive a response from ADFS and only have a single attribute in there (the mail address). So this line https://github.com/flipboxfactory/saml-sp/blob/2176913dfdb79e819289c2d19bf61496a80a42c4/src/services/login/User.php#L153 will set $hasAttributes to false although it has one correct attribute.

Because of that

When we change the line to $hasAttributes = count($assertion->getAttributes()) > 0; everything works as expected.

From our point of view this seems like a bug (which will work in almost all cases, because nearly all of the cases have more than one attribute) and additionally it reads strange ("If you have ONE attribute, the property hasAttributes is set to false, which leads to the assumption the there is NO attribute").

Could you give us advice on how to handle this problem on our side correct OR how to fix it and why you had decided to always expect more than 1 attribute and fail if there is only one.

Best regards Michael

dsmrt commented 4 years ago

Good catch ... that does seem like a bug. You greater than zero logic seems correct. We just want at least one attribute. I'll get this patched up.

dsmrt commented 4 years ago

Fixed in 2.1.4.