PHPackages                             uconn-its/caspian - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. uconn-its/caspian

ActiveLibrary

uconn-its/caspian
=================

UConn's CAS Authentication Library

1.0.6(1y ago)0107↓100%Apache-2.0PHPPHP &gt;=8.1

Since May 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jpr21010/caspian)[ Packagist](https://packagist.org/packages/uconn-its/caspian)[ RSS](/packages/uconn-its-caspian/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

CASpian
=======

[](#caspian)

CASpian is an authentication library for Central Authentication Service (CAS) 3.0 protocol.

CASpian is inspired by the original apereo/phpCAS, but designed to be more flexible and easier to use for our needs.

Installation
------------

[](#installation)

```
composer require aurora/caspian
```

Usage
-----

[](#usage)

For the most part, CASpian is a drop-in replacement for phpCAS, with only slight differences in the method names and parameters.

The first step is to decide on a storage backend for the CASpian client. The storage backend is used to store the CAS session information.

### Storage Backends

[](#storage-backends)

CASpian comes with two storage backends out of the box: `CASPian\Storage\SessionStorageProvider` and `CASPian\Storage\RedisStorageProvider` which use PHP's $\_SESSION and Redis respectively.

You can use the `CASPian\Storage\SessionStorageProvider` by calling the `CASPian\Caspian::sessionProvider()` method.

```
$storage = CASPian\Caspian::sessionProvider();
```

You can use the `CASPian\Storage\RedisStorageProvider` by calling the `CASPian\Caspian::redisProvider()` method.

```
// 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');
```

You can also implement your own storage backend by implementing the `CASPian\CaspianStorageProvider` interface.

### Client Setup

[](#client-setup)

Once you have a storage backend, you can set up the CASpian client by calling the `CASPian\Caspian::client()` method.

```
// 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);
```

There are also some configuration options that you can set on the client.

```
\CASpian\Caspian::disableRemoveTicketRedirect(); // Disables removing the ticket from the URL after a successful login
```

### Using the Client

[](#using-the-client)

Once the client is set up, here are some of the methods you can use to authenticate users.

The `isAuthenticated()` method checks if the user is authenticated.

```
if (\CASpian\Caspian::isAuthenticated()) {
    // User is authenticated
    echo 'Hello, ' . \CASpian\Caspian::getUser();
}
```

The `forceAuthentication()` method ensures that any code that follows it will only be executed if the user is authenticated. If the user is not authenticated, the user will be redirected to the CAS server to log in.

```
\CASpian\Caspian::forceAuthentication();

// Code that should only be executed if the user is authenticated
echo 'Hello, ' . \CASpian\Caspian::getUser();
```

The `logout()` method logs the user out and redirects them to the CAS server to log out. You can also pass a URL to redirect the user to after logging out. If you want to log the user out and stay on the same page, you can pass the current URL as the redirect URL. After the logout() method is called, code execution will stop.

```
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');
}
```

The `getUser()` method returns the username of the authenticated user. If the user is not authenticated, it will return null. Note: you must call `isAuthenticated()` or `forceAuthentication()` at some point before calling `getUser()`otherwise the existing session may not be loaded into the client.

```
\CASpian\Caspian::forceAuthentication();

echo 'Hello, ' . \CASpian\Caspian::getUser();
```

The `getAttributes()` method returns an array of attributes for the authenticated user if configured by the CAS server. If the user is not authenticated, it will return an empty array. Note: you must call `isAuthenticated()` or `forceAuthentication()` at some point before calling `getAttributes()` otherwise the existing session may not be loaded into the client.

```
\CASpian\Caspian::forceAuthentication();

$attributes = \CASpian\Caspian::getAttributes();
echo 'Hello, ' . $attributes['givenName'];

// You can also get a specific attribute
echo 'Hello, ' . \CASpian\Caspian::getAttribute('givenName');
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance52

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

367d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/70209d3a3264503261b9a109bf4c0328f5127a28a3b9a416d8143dea3c893aa3?d=identicon)[jpr21010](/maintainers/jpr21010)

---

Top Contributors

[![jpr21010](https://avatars.githubusercontent.com/u/176041136?v=4)](https://github.com/jpr21010 "jpr21010 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/uconn-its-caspian/health.svg)

```
[![Health](https://phpackages.com/badges/uconn-its-caspian/health.svg)](https://phpackages.com/packages/uconn-its-caspian)
```

###  Alternatives

[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k4](/packages/elgg-elgg)[neos/flow

Flow Application Framework

862.0M449](/packages/neos-flow)[api-platform/metadata

API Resource-oriented metadata attributes and factories

223.5M96](/packages/api-platform-metadata)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[flowwow/cloudpayments-php-client

cloudpayments api client

2188.2k](/packages/flowwow-cloudpayments-php-client)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
