-
-
Notifications
You must be signed in to change notification settings - Fork 503
Expand file tree
/
Copy pathslo.php
More file actions
39 lines (29 loc) · 1.13 KB
/
slo.php
File metadata and controls
39 lines (29 loc) · 1.13 KB
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 initiate a SAML Single Log Out request
*
* When the user visits this URL, the browser will be redirected to the SLO
* IdP with an SLO request.
*/
session_start();
require_once dirname(__DIR__).'/_toolkit_loader.php';
use OneLogin\Saml2\LogoutRequest;
use OneLogin\Saml2\Settings;
use OneLogin\Saml2\Utils;
/** @var \GuzzleHttp\Psr7\ServerRequest $request */
$request = \GuzzleHttp\Psr7\ServerRequest::fromGlobals();
$samlSettings = new Settings();
$idpData = $samlSettings->getIdPData();
if (isset($idpData['singleLogoutService']) && isset($idpData['singleLogoutService']['url'])) {
$sloUrl = $idpData['singleLogoutService']['url'];
} else {
throw new Exception("The IdP does not support Single Log Out");
}
if (isset($_SESSION['IdPSessionIndex']) && !empty($_SESSION['IdPSessionIndex'])) {
$logoutRequest = new LogoutRequest($samlSettings, null, $_SESSION['IdPSessionIndex']);
} else {
$logoutRequest = new LogoutRequest($samlSettings);
}
$samlRequest = $logoutRequest->getRequest();
$parameters = array('SAMLRequest' => $samlRequest);
return Utils::redirect($sloUrl, $parameters);