Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende ÜberarbeitungLetzte ÜberarbeitungBeide Seiten der Revision | ||
de:shibslohttpd:helperscripts [2015/12/08 16:06] – Schreiterer, Frank | de:shibslohttpd:helperscripts [2015/12/09 11:37] – [sessionremover.php] Schreiterer, Frank | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== | + | ====== |
+ | |||
+ | Alle hier aufgeführten Skripte sind beispielhaft und müssen ggf. angepasst werden. | ||
+ | |||
+ | ===== checker.php ===== | ||
+ | |||
+ | Sorgt für den notwendigen zusätzlichen Request beim SessionHook. | ||
+ | <file php checker.php> | ||
+ | <?php | ||
+ | //redirect to application | ||
+ | header(' | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | ===== initsess.php ===== | ||
+ | <file php initsess.php> | ||
+ | <?php | ||
+ | // | ||
+ | session_start(); | ||
+ | // | ||
+ | $path = " | ||
+ | //and redirect to application | ||
+ | $redirect = " | ||
+ | header(' | ||
+ | ?> | ||
+ | </ | ||
===== logoutnotify.php ===== | ===== logoutnotify.php ===== | ||
- | <file php> | + | Dieses Skript [[de: |
+ | |||
+ | < | ||
<?php | <?php | ||
// Sample PHP 5 Shibboleth logout code by lukas.haemmerle@switch.change_user | // Sample PHP 5 Shibboleth logout code by lukas.haemmerle@switch.change_user | ||
Zeile 165: | Zeile 192: | ||
// SessionID is stored in the user session data! | // SessionID is stored in the user session data! | ||
| | ||
- | | ||
- | // | ||
- | $dbDriver=" | ||
- | $dbHost=" | ||
- | $dbUser=" | ||
- | $dbPass=" | ||
- | $dbName=" | ||
- | $dbPort=" | ||
- | |||
// | // | ||
$mcsrv=" | $mcsrv=" | ||
$mcport=" | $mcport=" | ||
- | + | ||
- | //mode memcached or DB | + | $mc=new Memcache; |
- | $mode = " | + | $mc-> |
- | #$mode = " | + | //get the application session id |
- | + | $appsessionid = $mc-> | |
- | if ($mode == " | + | //remove |
- | //Remove the entry in shibchecker-DB and the aplication session | + | $ret = $mc-> delete($SessionID); |
- | try { | + | $ret = $mc-> delete($appsessionid); |
- | $pdo = new PDO(" | + | if ($appsessionid == false) { |
- | //get the application session id | + | $appsessionid = ""; |
- | $sqlappsess=" | + | |
- | $appsessionid = ""; | + | |
- | if ($res = $pdo-> | + | |
- | while ($row = $res-> | + | |
- | $appsessionid = $row[' | + | |
- | } | + | |
- | } | + | |
- | if ($appsessionid != "" | + | |
- | $sql=" | + | |
- | $pdo-> | + | |
- | $pdo = NULL; | + | |
- | } | + | |
- | } catch (PDOExeption $e) { | + | |
- | return new SoapFault(' | + | |
- | } | + | |
- | } elseif ($mode == " | + | |
- | $mc=new Memcache; | + | |
- | $mc-> | + | |
- | //get the application session id | + | |
- | $appsessionid = $mc-> | + | |
- | //remove | + | |
- | $ret = $mc-> delete($SessionID); | + | |
- | $ret = $mc-> delete($appsessionid); | + | |
- | if ($appsessionid == false) { | + | |
- | $appsessionid = ""; | + | |
- | } | + | |
} | } | ||
+ | |||
//Connect to the application session (PHP Session) | //Connect to the application session (PHP Session) | ||
session_id($appsessionid); | session_id($appsessionid); | ||
Zeile 224: | Zeile 217: | ||
?> | ?> | ||
</ | </ | ||
+ | |||
+ | ===== remsess.php ===== | ||
+ | |||
+ | <file php remsess.php> | ||
+ | <?php | ||
+ | |||
+ | /* | ||
+ | This program is free software: you can redistribute it and/or modify | ||
+ | it under the terms of the GNU General Public License as published by | ||
+ | the Free Software Foundation, either version 3 of the License, or | ||
+ | any later version. | ||
+ | |||
+ | This program is distributed in the hope that it will be useful, | ||
+ | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
+ | GNU General Public License for more details. | ||
+ | |||
+ | You should have received a copy of the GNU General Public License | ||
+ | along with this program. | ||
+ | | ||
+ | Copyright 2015 Frank Schreiterer, | ||
+ | */ | ||
+ | |||
+ | function removeMemcached($destid) { | ||
+ | $mcsrv=" | ||
+ | $mcport=" | ||
+ | $mc=new Memcache; | ||
+ | $mc-> | ||
+ | $stats = $mc-> | ||
+ | $list = array(); | ||
+ | #memcached auslesen und bei passendem Wert den Key entfernen | ||
+ | $allSlabs = $mc-> | ||
+ | $items = $mc-> | ||
+ | foreach($allSlabs as $server => $slabs) { | ||
+ | foreach($slabs AS $slabId => $slabMeta) { | ||
+ | if (is_numeric($slabId)) { | ||
+ | $cdump = $mc-> | ||
+ | foreach($cdump AS $keys => $arrVal) { | ||
+ | if (!is_array($arrVal)) continue; | ||
+ | foreach($arrVal AS $k => $v) { | ||
+ | $get = $mc-> | ||
+ | if ($get == $destid) { | ||
+ | $ret = $mc-> | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | #und bei mixedLazy den Sicherungseintrag zur destid | ||
+ | $ret = $mc-> | ||
+ | $mc-> | ||
+ | } | ||
+ | |||
+ | #eine böse Anwendungs-Session-ID zerstören | ||
+ | if (isset($_REQUEST[' | ||
+ | $destid = $_REQUEST[' | ||
+ | if ($destid != "" | ||
+ | session_id($destid); | ||
+ | removeMemcached($destid); | ||
+ | session_start(); | ||
+ | session_destroy(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | session_start(); | ||
+ | $serverurl=" | ||
+ | if (isset($_REQUEST[' | ||
+ | $shiblogoff = $_REQUEST[' | ||
+ | if ($shiblogoff == " | ||
+ | echo "Sie wurden abgemeldet.< | ||
+ | } | ||
+ | } else { | ||
+ | |||
+ | $destid = session_id(); | ||
+ | removeMemcached($destid); | ||
+ | |||
+ | $url=" | ||
+ | header(' | ||
+ | } | ||
+ | |||
+ | session_destroy(); | ||
+ | # | ||
+ | setcookie(session_name(),"", | ||
+ | ?> | ||
+ | |||
+ | </ | ||
+ | |||