Skip to content

Commit

Permalink
Merge pull request #2 from kabel/master
Browse files Browse the repository at this point in the history
Add gateway & renew features and increase abstraction
  • Loading branch information
saltybeagle committed Dec 6, 2011
2 parents 0402ef4 + 604dba1 commit af56b6b
Show file tree
Hide file tree
Showing 6 changed files with 413 additions and 169 deletions.
1 change: 1 addition & 0 deletions docs/examples/simple.php
Expand Up @@ -23,4 +23,5 @@
echo '<p>The user\'s login is '.$client->getUsername().'</p>';
}
?>
<a href="simple_renew.php">Super Sensitive Page</a>
<a href="?logout">Logout</a>
28 changes: 28 additions & 0 deletions docs/examples/simple_gateway.php
@@ -0,0 +1,28 @@
<?php
ini_set('display_errors', true);
set_include_path(dirname(dirname(__DIR__)).'/src'.PATH_SEPARATOR.dirname(dirname(__DIR__)).'/vendor/php');
require_once 'SimpleCAS/Autoload.php';
require_once 'HTTP/Request2.php';

$options = array('hostname' =>'login.unl.edu',
'port' => 443,
'uri' => 'cas');
$protocol = new SimpleCAS_Protocol_Version2($options);

$protocol->getRequest()->setConfig('ssl_verify_peer', false);

$client = SimpleCAS::client($protocol);
$client->gatewayAuthentication();
?>
<?php if ($client->isAuthenticated()): ?>
<?php if (isset($_GET['logout'])) {
$client->logout();
} ?>
<h1>Authentication Successful!</h1>
<p>The user's login is <?php echo $client->getUsername() ?></p>
<p>View the <a href="simple.php">authenticated home page</a></p>
<a href="?logout">Logout</a>
<?php else: ?>
<h1>NOT Authenticated</h1>
<p><a href="simple.php">Login</a> to see more</p>
<?php endif; ?>
27 changes: 27 additions & 0 deletions docs/examples/simple_renew.php
@@ -0,0 +1,27 @@
<?php
ini_set('display_errors', true);
set_include_path(dirname(dirname(__DIR__)).'/src'.PATH_SEPARATOR.dirname(dirname(__DIR__)).'/vendor/php');
require_once 'SimpleCAS/Autoload.php';
require_once 'HTTP/Request2.php';

$options = array('hostname' =>'login.unl.edu',
'port' => 443,
'uri' => 'cas');
$protocol = new SimpleCAS_Protocol_Version2($options);

$protocol->getRequest()->setConfig('ssl_verify_peer', false);

$client = SimpleCAS::client($protocol);

if (isset($_GET['logout'])) {
$client->logout();
}

$client->renewAuthentication();

if ($client->isAuthenticated()) {
echo '<h1>Authentication Successful!</h1>';
echo '<p>Welcome to the renewed auth page.</p>';
}
?>
<a href="?logout">Logout</a>

0 comments on commit af56b6b

Please sign in to comment.