Skip to content

Commit 36a22ca

Browse files
committed
Merge pull request SAML-Toolkits#74 from davidstrauss/patch-1
Show the NameID data in the example
2 parents 16c08a9 + 6943b1c commit 36a22ca

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -609,14 +609,18 @@ if (!$auth->isAuthenticated()) {
609609
}
610610

611611
$_SESSION['samlUserdata'] = $auth->getAttributes();
612+
$_SESSION['samlNameId'] = $auth->getNameId();
612613
if (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

618622
if (!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

700704
Before 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

839844
We 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

842847
Note: Review the demo1 folder that contains that use case; in a later section we
843848
explain 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

Comments
 (0)