Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
de:shibslohttpd:helperscripts [2015/12/09 08:54] – [sessionremover.php] Schreiterer, Frankde:shibslohttpd:helperscripts [2019/02/28 12:25] (aktuell) – [logoutnotify.php] Schreiterer, Frank
Zeile 1: Zeile 1:
-====== Hilfsscripte ======+====== Hilfsskripte ====== 
 + 
 +Alle hier aufgeführten Skripte sind beispielhaft und müssen ggf. angepasst werden.
  
 ===== checker.php ===== ===== checker.php =====
 +
 +Sorgt für den notwendigen zusätzlichen Request beim SessionHook.
 <file php checker.php> <file php checker.php>
-<? php+<?php
 //redirect to application //redirect to application
 header('Location: '.$_GET['return']); header('Location: '.$_GET['return']);
 +?>
 +</file>
 +
 +===== initsess.php =====
 +<file php initsess.php>
 +<?php
 +//initialize application session
 +session_start();
 +//applicationpath
 +$path = "Path/to/NORMALAPPLICATION";
 +//and redirect to application
 +$redirect = "https://".$_SERVER['SERVER_NAME']."/$path";
 +header('Location: '.$redirect);
 ?> ?>
 </file> </file>
Zeile 11: Zeile 28:
  
 ===== logoutnotify.php ===== ===== logoutnotify.php =====
 +
 +Dieses Skript [[de:shibslohttpd:removallogout|entfernt die Anwendungs-Session]] via Back-Channel und die Cookies via Front-Channel.
  
 <file php logoutnotify.php> <file php logoutnotify.php>
Zeile 83: Zeile 102:
 //       See function LogoutNotification below //       See function LogoutNotification below
    
-elseif (!empty($HTTP_RAW_POST_DATA)) {+elseif (!empty(file_get_contents("php://input"))) {
     // Set SOAP header     // Set SOAP header
     $server = new SoapServer('https://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'/LogoutNotification.wsdl');     $server = new SoapServer('https://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'/LogoutNotification.wsdl');
Zeile 173: Zeile 192:
     // SessionID is stored in the user session data!     // SessionID is stored in the user session data!
          
-     
- //connection parameters to the shibcheckerdb 
- $dbDriver="mysql"; 
- $dbHost="localhost"; 
- $dbUser="shibuser"; 
- $dbPass="Password"; 
- $dbName="shibchecker"; 
- $dbPort="3306"; 
-  
  //connection parameters to memcached  //connection parameters to memcached
  $mcsrv="127.0.0.1";  $mcsrv="127.0.0.1";
  $mcport="11211";  $mcport="11211";
-  + 
- //mode memcached or DB + $mc=new Memcache; 
- $mode = "memcached"; + $mc->connect($mcsrv,$mcport); 
- #$mode = "DB"; + //get the application session id 
-  + $appsessionid = $mc->get($SessionID); 
- if ($mode == "DB") {     + //remove  
- //Remove the entry in shibchecker-DB and the aplication session         + $ret = $mc-> delete($SessionID); 
- try { + $ret = $mc-> delete($appsessionid); 
- $pdo = new PDO("$dbDriver:dbname=$dbName;host=$dbHost;port=$dbPort",$dbUser,$dbPass); + if ($appsessionid == false) { 
- //get the application session id + $appsessionid = "";
- $sqlappsess="Select appsessionid from appshibsession where shibsessionid='$SessionID'"; +
- $appsessionid = ""; +
- if ($res = $pdo->query($sqlappsess)) { +
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) { +
- $appsessionid = $row['appsessionid']; +
-+
- }  +
- if ($appsessionid != "") {  +
- $sql="Delete from appshibsession where appsessionid='$appsessionid'"; +
- $pdo->query($sql);  +
- $pdo = NULL;  +
- }  +
- } catch (PDOExeption $e) {  +
- return new SoapFault('LogoutError', 'Database error.'); +
- }  +
- } elseif ($mode == "memcached") { +
- $mc=new Memcache; +
- $mc->connect($mcsrv,$mcport); +
- //get the application session id +
- $appsessionid = $mc->get($SessionID); +
- //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 233: Zeile 218:
 </file> </file>
  
-===== sessionremover.php =====+===== remsess.php =====
  
-<file php SESSIONREMOVER.php>+<file php remsess.php>
 <?php <?php
  
 /* /*
-    This program is free software: you can redistribute it and/or modify+ 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     it under the terms of the GNU General Public License as published by
     the Free Software Foundation, either version 3 of the License, or     the Free Software Foundation, either version 3 of the License, or
Zeile 254: Zeile 239:
     Copyright 2015 Frank Schreiterer, University of Bamberg, Computing Centre          Copyright 2015 Frank Schreiterer, University of Bamberg, Computing Centre     
 */  */ 
- 
-#modus memcached oder DB 
-$mode = "memcached"; 
- 
-function removeDB ($destid) { 
- $dbDriver="mysql"; 
- $dbHost="localhost"; 
- $dbUser="shibUser"; 
- $dbPass="Password"; 
- $dbName="shibchecker"; 
- $dbPort="3306"; 
- try { 
- $pdo = new PDO("$dbDriver:dbname=$dbName;host=$dbHost;port=$dbPort",$dbUser,$dbPass); 
- } catch (PDOExeption $e) { } 
- $sql="Delete from appshibsession where appsessionid='$destid'"; 
- $pdo->query($sql);  
- $pdo = NULL; 
-} 
  
 function removeMemcached($destid) { function removeMemcached($destid) {
-    $mcsrv="127.0.0.1"; + $mcsrv="127.0.0.1"; 
-    $mcport="11211"; + $mcport="11211"; 
-    $mc=new Memcache; + $mc=new Memcache; 
-    $mc->connect($mcsrv,$mcport); + $mc->connect($mcsrv,$mcport); 
-    $stats = $mc->getExtendedStats();+ $stats = $mc->getExtendedStats();
     $list = array();     $list = array();
     #memcached auslesen und bei passendem Wert den Key entfernen     #memcached auslesen und bei passendem Wert den Key entfernen
Zeile 309: Zeile 276:
  if ($destid != "") {  if ($destid != "") {
  session_id($destid);  session_id($destid);
- if ($mode == "DB") { + removeMemcached($destid);
- removeDB($destid); +
- } elseif ($mode == "memcached") { +
- removeMemcached($destid); +
- }+
  session_start();   session_start();
  session_destroy();   session_destroy();
Zeile 324: Zeile 287:
  $shiblogoff = $_REQUEST['shibloggedoff'];  $shiblogoff = $_REQUEST['shibloggedoff'];
  if ($shiblogoff == "true") {  if ($shiblogoff == "true") {
- echo "Sie wurden abgemeldet.<br><br>Erneut <a href=\"$serverurl/logouttest/lazy\">mit Lazy-Sesson anmelden</a><br> + echo "Sie wurden abgemeldet.<br><br>Erneut <a href=\"$serverurl/PATH/TO/Login\">anmelden</a><br>";
- oder <a href=\"$serverurl/logouttest/mixedlazy\">mit Lazy-Sesson oder Anwendungssession anmelden</a><br+
- oder <a href=\"$serverurl/logouttest/normal\">mit normaler Sesson anmelden</a><br><br>";  +
- echo "Von allen Webanwendungen <a href=\"https://weblogout.rz.uni-bamberg.de\">abmelden.</a>"; +
  }  }
 } else { } else {
   
  $destid = session_id();  $destid = session_id();
- if ($mode == "DB") { + removeMemcached($destid);
- removeDB($destid); +
- } elseif ($mode == "memcached") { +
- removeMemcached($destid);  +
- }+
   
- $url="$serverurl/Shibboleth.sso/Logout?return=$serverurl/logouttest/logout/remsess.php?shibloggedoff=true";+ $url="$serverurl/Shibboleth.sso/Logout?return=$serverurl/PATH/TO/remsess.php?shibloggedoff=true";
  header('Location: '.$url);  header('Location: '.$url);
 } }
  • Zuletzt geändert: vor 9 Jahren