Beispiel #1
0
require __DIR__ . '/../vendor/autoload.php';
session_start();
$config = (require __DIR__ . '/config.php');
$url = parse_url($_SERVER['REQUEST_URI']);
$action = ltrim($url['path'], '/');
set_exception_handler(function ($e) {
    if ($e instanceof \P7\SSO\Exception\ApiException && $e->getCode() === 401) {
        unset($_SESSION['tokens']);
    }
    $exception = $e;
    require 'partial/exception.php';
});
//creates configuration
$ssoConfig = new P7\SSO\Configuration($config);
//creates SSO object
$sso = new P7\SSO($ssoConfig);
$callbackUri = $config['redirect_uri'];
function getSessionTokens($throws = false)
{
    if ($throws && empty($_SESSION['tokens'])) {
        throw new \Exception("No session tokens");
    }
    return empty($_SESSION['tokens']) ? null : new \P7\SSO\TokenSet($_SESSION['tokens']);
}
function authenticatedRedirect()
{
    $tokens = getSessionTokens();
    if (!$tokens) {
        return false;
    }
    header('Location: /account');
Beispiel #2
0
use P7\SSO\Exception\AuthorizeCallbackException;
session_start();
$config = (require __DIR__ . '/config.php');
$url = parse_url($_SERVER['REQUEST_URI']);
$action = ltrim($url['path'], '/');
set_exception_handler(function ($e) {
    if ($e instanceof \P7\SSO\Exception\ApiException && $e->getCode() === 401) {
        unset($_SESSION['tokens']);
    }
    $exception = $e;
    require 'partial/exception.php';
});
//creates configuration
$ssoConfig = new P7\SSO\Configuration($config);
//creates SSO object
$sso = new P7\SSO($ssoConfig);
$callbackUri = $config['redirect_uri'];
function getSessionTokens($throws = false)
{
    if ($throws && empty($_SESSION['tokens'])) {
        throw new \Exception("No session tokens");
    }
    return empty($_SESSION['tokens']) ? null : new \P7\SSO\TokenSet($_SESSION['tokens']);
}
function authenticatedRedirect()
{
    $tokens = getSessionTokens();
    if (!$tokens) {
        return false;
    }
    header('Location: /account');