@@ -609,14 +609,18 @@ if (!$auth->isAuthenticated()) {
609609}
610610
611611$_SESSION['samlUserdata'] = $auth->getAttributes();
612+ $_SESSION['samlNameId'] = $auth->getNameId();
612613if (isset($_POST['RelayState']) && OneLogin_Saml2_Utils::getSelfURL() != $_POST['RelayState']) {
613614    $auth->redirectTo($_POST['RelayState']);
614615}
615616
616617$attributes = $_SESSION['samlUserdata'];
618+ $nameId = $_SESSION['samlNameId'];
619+ 
620+ echo '<h1 >Identified user: '. htmlentities($nameId) .'</h1 >';
617621
618622if (!empty($attributes)) {
619-     echo '<h1 >'._('User attributes:').'</h1 >';
623+     echo '<h2 >'._('User attributes:').'</h2 >';
620624    echo '<table ><thead ><th >'._('Name').'</th ><th >'._('Values').'</th ></thead ><tbody >';
621625    foreach ($attributes as $attributeName => $attributeValues) {
622626        echo '<tr ><td >' . htmlentities($attributeName) . '</td ><td ><ul >';
@@ -627,7 +631,7 @@ if (!empty($attributes)) {
627631    }
628632    echo '</tbody ></table >';
629633} else {
630-     echo _('Attributes not  found');
634+     echo _('No attributes  found. ');
631635}
632636``` 
633637
@@ -698,10 +702,11 @@ print_r($auth->getAttribute('cn'));
698702
699703
700704Before trying to get an attribute, check that the user is
701- authenticated. If the user isn't authenticated, an empty
702- array will be returned. For example, if we call to getAttributes
703- before a $auth->processResponse, the getAttributes() will return
704- an empty array.
705+ authenticated. If the user isn't authenticated or if there were
706+ no attributes in the SAML assertion, an empty array will be
707+ returned. For example, if we call to getAttributes before a
708+ $auth->processResponse, the getAttributes() will return an
709+ empty array.
705710
706711
707712##### Single Logout Service (SLS) endpoints/sls.php  ##### 
@@ -837,7 +842,7 @@ $auth->logout($newTargetUrl);
837842#### Example of a view that initiates the SSO request and handles the response (is the acs target)  #### 
838843
839844We can code a unique file that initiates the SSO process, handle the response, get the attributes, initiate 
840- the slo  and processes the logout response.
845+ the SLO  and processes the logout response.
841846
842847Note: Review the demo1 folder that contains that use case; in a later section we
843848explain the demo1 use case further in detail.
@@ -1269,7 +1274,7 @@ demo1, only changes the targets.
12691274    user is logged and redirects to index.php, so we will be in the
12701275    index.php at the end.
12711276
1272-  3 .  We are logged into the app and the user attributes are shown. 
1277+  3 .  We are logged into the app and the user attributes (if any)  are shown. 
12731278    At this point, we can test the single log out functionality.
12741279
12751280 4 .  The single log out funcionality could be tested by 2 ways.
0 commit comments