Beispiel #1
0
<?php

require_once __DIR__ . '/../../vendor/autoload.php';
if (isset($_GET['sso_error'])) {
    header("Location: error.php?sso_error=" . $_GET['sso_error'], true, 307);
    exit;
}
$broker = new Jasny\SSO\Broker(getenv('SSO_SERVER'), getenv('SSO_BROKER_ID'), getenv('SSO_BROKER_SECRET'));
$broker->attach(true);
$user = $broker->getUserInfo();
if (!$user) {
    header("Location: login.php", true, 307);
    exit;
}
?>
<!doctype html>
<html>
    <head>
        <title><?php 
echo $broker->broker;
?>
 (Single Sign-On demo)</title>
        <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">        
    </head>
    <body>
        <div class="container">
            <h1><?php 
echo $broker->broker;
?>
 <small>(Single Sign-On demo)</small></h1>
            <h3>Logged in</h3>
Beispiel #2
0
<?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">