Skip to content

Commit 28e9a10

Browse files
committed
Add logout link for the IdP SSO session (https://ssp.dev.openconext.local/logout.php)
1 parent 8c53e68 commit 28e9a10

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

docker/html/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ <h2 id="saml-metadata">SAML Metadata</h2>
3232
<h2 id="simplesamlphp">SimpleSAMLphp</h2>
3333
<ul>
3434
<li><a href="https://ssp.dev.openconext.local/simplesaml/admin">SimpleSAMLphp installation page (password: <code>secret</code>)</a></li>
35+
<li><a href="logout.php">End IdP SSP session (remove SimpleSAMLAuthToken cookie)</a></li>
3536
</ul>
3637

3738
<h2 id="test-accounts">Test accounts</h2>

docker/html/logout.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
const SSP_AUTH_COOKIE_NAME = 'SimpleSAMLAuthToken';
4+
5+
$cookie_was_set = false;
6+
7+
// Check if cookie is set
8+
if (isset($_COOKIE[SSP_AUTH_COOKIE_NAME])) {
9+
$cookie_was_set = true;
10+
// Send cookie header to unset cookie
11+
setcookie(SSP_AUTH_COOKIE_NAME, '', time() - 3600); // Expire cookie
12+
}
13+
14+
$message = '';
15+
if ($cookie_was_set) {
16+
$message = 'Deleted ' . SSP_AUTH_COOKIE_NAME . ' cookie.';
17+
} else {
18+
$message = SSP_AUTH_COOKIE_NAME . ' was not present.';
19+
}
20+
21+
$message = htmlspecialchars($message, ENT_QUOTES, 'UTF-8');
22+
23+
echo <<<HTML
24+
<html lang="en">
25+
<body>
26+
<p>$message</p>
27+
<p>
28+
<a href="/">Home</a>
29+
</p>
30+
</body>
31+
</html>
32+
HTML;

0 commit comments

Comments
 (0)