Created
September 9, 2013 13:54
-
-
Save asgrim/6495890 to your computer and use it in GitHub Desktop.
SSO idea (don't use this - it's not secure, it's just an academic idea)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once('shared.php'); | |
$user = 'james'; | |
$sig = generateSignature($user); | |
sleep(1); | |
header('Location: ' . $siteUrl . '?user=' . $user . '&sig=' . $sig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL ^ E_NOTICE); | |
require_once('shared.php'); | |
session_start(); | |
if ($_GET['logout'] == '1') | |
{ | |
unset($_SESSION['user']); | |
header('Location: ' . $siteUrl); | |
} | |
else if ($_SESSION['user']) | |
{ | |
echo "Logged in (from session)... user=" . $_SESSION['user'] . ".</p>"; | |
echo "<a href=\"{$siteUrl}?logout=1\">Logout</a>"; | |
} | |
else if ($_GET['user'] && !$_SESSION['user']) | |
{ | |
if (generateSignature($_GET['user']) == $_GET['sig']) | |
{ | |
$_SESSION['user'] = $_GET['user']; | |
header('Location: ' . $siteUrl); | |
} | |
else | |
{ | |
echo "Login failed."; | |
} | |
} | |
else | |
{ | |
echo "Not logged in.</p>"; | |
echo "<a href=\"{$providerUrl}\">Login</a>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment