Fix no iteration over all saml attr

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-10-29 20:31:04 +01:00
parent f0c4a51a1d
commit 5a69c05516

View File

@@ -26,12 +26,14 @@ func ExtractAttributeValue(assertion *saml.Assertion, attributeName string) (str
return "", fmt.Errorf("no attribute statement in assertion")
}
for _, attr := range assertion.AttributeStatements[0].Attributes {
if attr.Name == attributeName {
if len(attr.Values) == 0 {
return "", fmt.Errorf("attribute %q has no values", attributeName)
for _, statement := range assertion.AttributeStatements {
for _, attr := range statement.Attributes {
if attr.Name == attributeName {
if len(attr.Values) == 0 {
return "", fmt.Errorf("attribute %q has no values", attributeName)
}
return attr.Values[0].Value, nil
}
return attr.Values[0].Value, nil
}
}