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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. uconn-its/caspian

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

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

UConn's CAS Authentication Library

1.0.6(1y ago)0154Apache-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 3w 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

30

—

LowBetter than 62% of packages

Maintenance46

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

413d 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

[google/auth

Google Auth Library for PHP

1.4k286.7M205](/packages/google-auth)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.8M211](/packages/simplesamlphp-simplesamlphp)[simplesamlphp/saml2

SAML2 PHP library from SimpleSAMLphp

30417.8M41](/packages/simplesamlphp-saml2)[web-auth/webauthn-lib

FIDO2/Webauthn Support For PHP

1237.8M120](/packages/web-auth-webauthn-lib)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

51390.8k2](/packages/web-auth-webauthn-framework)

PHPackages © 2026

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