@@ -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