<?php use Jasny\SSO\NotAttachedException; require_once __DIR__ . '/../../vendor/autoload.php'; $broker = new Jasny\SSO\Broker(getenv('SSO_SERVER'), getenv('SSO_BROKER_ID'), getenv('SSO_BROKER_SECRET')); $broker->attach(true); try { if (!empty($_GET['logout'])) { $broker->logout(); } elseif ($broker->getUserInfo() || $_SERVER['REQUEST_METHOD'] == 'POST' && $broker->login($_POST['username'], $_POST['password'])) { header("Location: index.php", true, 303); exit; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $errmsg = "Login failed"; } } catch (NotAttachedException $e) { header('Location: ' . $_SERVER['REQUEST_URI']); exit; } catch (Jasny\SSO\Exception $e) { $errmsg = $e->getMessage(); } ?> <!doctype html> <html> <head> <title><?php echo $broker->broker; ?> | Login (Single Sign-On demo)</title> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">