/** * Constructor */ public function __construct(GenericUser $user = null) { //$this->middleware('auth'); if (config('shibboleth.emulate_idp') == true) { $this->config = new \Shibalike\Config(); $this->config->idpUrl = 'idp'; $stateManager = $this->getStateManager(); $this->sp = new \Shibalike\SP($stateManager, $this->config); $this->sp->initLazySession(); $this->idp = new \Shibalike\IdP($stateManager, $this->getAttrStore(), $this->config); } $this->user = $user; }
<?php /** * This demonstrates the emulation of "lazy" sessions. The $_SERVER attributes will only * be appended to if the user's shibalike session is valid. */ require '_inc.php'; $sp = new Shibalike\SP(getStateManager(), getConfig()); $sp->initLazySession(); // the "application" // _SERVER vars may not exist! $name = empty($_SERVER['displayname']) ? 'Anonymous' : $_SERVER['displayname']; header('Content-Type: text/html;charset=utf-8'); echo "<h1>Hello, " . htmlspecialchars($name, ENT_QUOTES, 'UTF-8') . "!</h1>"; echo "<p>This is a non-protected resource with a \"lazy\" session. Access the <a href='protected.php'>protected resource</a>.</p>"; echo "<p><a href='sp.php?sign-in'>Sign in</a> | <a href='sp.php?sign-out'>Sign out</a></p>";
<?php /** * Note, this script is just to emulate browser redirect flow in Shibboleth. You can use * the SP methods in any location (before headers are sent) */ // the "SP" require '_inc.php'; $sp = new Shibalike\SP(getStateManager(), getConfig()); if (isset($_GET['sign-in'])) { $from = $_SERVER['HTTP_REFERER']; $sp->makeAuthRequest($_SERVER['HTTP_REFERER']); $sp->redirect(); } else { // sign-out $sp->logout(); $sp->redirect('goodbye.php'); }
/** * Emulate a logout via Shibalike */ public function emulateLogout() { $this->sp->logout(); die('Goodbye, fair user. <a href="' . $this->getServerVariable('HTTP_REFERER') . '">Return from whence you came</a>!'); }
<?php // the "SP" require '_inc.php'; $sp = new Shibalike\SP(getStateManager(), getConfig()); $sp->requireValidUser(); // your app's shibboleth auth module here $username = $_SERVER['glid']; // the "application" header('Content-Type: text/html;charset=utf-8'); echo "<h1>Hello, " . htmlspecialchars($_SERVER['businessName'], ENT_QUOTES, 'UTF-8') . "!</h1>"; echo "<p><a href='idp/?logout'>Sign out</a></p>";