Skip to content

Commit 5f90a33

Browse files
committed
remove extra values from shib attributes
typo
1 parent a85da39 commit 5f90a33

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

resources/lib/UnitySSO.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,27 @@ private static function eppnToOrg($eppn)
2626
return strtolower($org);
2727
}
2828

29+
private static function getAttribute($attributeName, $fallbackAttributeName = null)
30+
{
31+
if (!is_null($fallbackAttributeName) && !(isset($_SERVER[$attributeName]))) {
32+
$attribute = UnitySite::arrayGetOrBadRequest($_SERVER, $fallbackAttributeName);
33+
} else {
34+
$attribute = UnitySite::arrayGetOrBadRequest($_SERVER, $attributeName);
35+
}
36+
// shib attributes may have multiple values, by default they are split by ';'
37+
// see SPConfig setting attributeValueDelimiter
38+
return explode(";", $attribute)[0];
39+
}
40+
2941
public static function getSSO()
3042
{
3143
return array(
32-
"user" => self::eppnToUID($_SERVER["REMOTE_USER"]),
33-
"org" => self::eppnToOrg($_SERVER["REMOTE_USER"]),
34-
"firstname" => $_SERVER["givenName"],
35-
"lastname" => $_SERVER["sn"],
36-
"name" => $_SERVER["givenName"] . " " . $_SERVER["sn"],
37-
"mail" => isset($_SERVER["mail"]) ? $_SERVER["mail"] : $_SERVER["eppn"]
44+
"user" => self::eppnToUID(self::getAttribute("REMOTE_USER")),
45+
"org" => self::eppnToOrg(self::getAttribute("REMOTE_USER")),
46+
"firstname" => self::getAttribute("givenName"),
47+
"lastname" => self::getAttribute("sn"),
48+
"name" => self::getAttribute("givenName") . " " . self::getAttribute("sn"),
49+
"mail" => self::getAttribute("mail", "eppn")
3850
);
3951
}
4052
}

0 commit comments

Comments
 (0)