1. Go to this page and download the library: Download uconn-its/caspian library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
uconn-its / caspian example snippets
$storage = CASPian\Caspian::sessionProvider();
// For redis servers with no authentication
$storage = CASPian\Caspian::redisProvider('localhost', 6379);
// For redis servers with password authentication
$storage = CASPian\Caspian::redisProvider('localhost', 6379, 'password');
// By default, the client will be created with no logging
\CASpian\Caspian::client('https://cas.example.edu', 'https://www.service.com', $storage);
// You may pass a PSR-3 logger to the client to enable logging
// Here we use Monolog to log to stdout at the DEBUG level
$logger = new Monolog\Logger('caspian');
$logger->pushHandler(new Monolog\Handler\StreamHandler('php://stdout', Monolog\Logger::DEBUG));
\CASpian\Caspian::client('https://cas.example.edu', 'https://www.service.com', $storage, $logger);
\CASpian\Caspian::disableRemoveTicketRedirect(); // Disables removing the ticket from the URL after a successful login
if (\CASpian\Caspian::isAuthenticated()) {
// User is authenticated
echo 'Hello, ' . \CASpian\Caspian::getUser();
}
\CASpian\Caspian::forceAuthentication();
// Code that should only be executed if the user is authenticated
echo 'Hello, ' . \CASpian\Caspian::getUser();
if (isset($_GET['logout'])) {
\CASpian\Caspian::logout();
}
// Optionally, you can pass a URL to redirect the user to after logging out
if (isset($_GET['logout'])) {
\CASpian\Caspian::logout('https://www.example.com');
}
\CASpian\Caspian::forceAuthentication();
$attributes = \CASpian\Caspian::getAttributes();
echo 'Hello, ' . $attributes['givenName'];
// You can also get a specific attribute
echo 'Hello, ' . \CASpian\Caspian::getAttribute('givenName');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.