forked from SAML-Toolkits/php-saml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsume.php
39 lines (35 loc) · 1.39 KB
/
consume.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
* SAMPLE Code to demonstrate how to handle a SAML assertion response.
*
* The URL of this file will have been given during the SAML authorization.
* After a successful authorization, the browser will be directed to this
* link where it will send a certified response via $_POST.
*/
error_reporting(E_ALL);
$settings = null;
require 'settings.php';
$samlResponse = new OneLogin_Saml_Response($settings, $_POST['SAMLResponse']);
try {
if ($samlResponse->isValid()) {
echo 'You are: ' . $samlResponse->getNameId() . '<br>';
$attributes = $samlResponse->getAttributes();
if (!empty($attributes)) {
echo 'You have the following attributes:<br>';
echo '<table><thead><th>Name</th><th>Values</th></thead><tbody>';
foreach ($attributes as $attributeName => $attributeValues) {
echo '<tr><td>' . htmlentities($attributeName) . '</td><td><ul>';
foreach ($attributeValues as $attributeValue) {
echo '<li>' . htmlentities($attributeValue) . '</li>';
}
echo '</ul></td></tr>';
}
echo '</tbody></table><br><br>';
echo "The v.1 of the Onelogin's PHP SAML Tookit does not support SLO.";
}
} else {
echo 'Invalid SAML response.';
}
} catch (Exception $e) {
echo 'Invalid SAML response: ' . $e->getMessage();
}