PHPackages                             sfu/php-cas - 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. sfu/php-cas

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

sfu/php-cas
===========

PHP library for SFU CAS

5.0.3(10y ago)1191MITPHP

Since May 29Pushed 10y ago3 watchersCompare

[ Source](https://github.com/sfu/php-cas)[ Packagist](https://packagist.org/packages/sfu/php-cas)[ RSS](/packages/sfu-php-cas/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

php-cas
=======

[](#php-cas)

php-cas is a library for Simon Fraser University's slightly-modified version of JASIG CAS, the Central Authentication System. It should work with standard CAS implementations, but has been customized for authorization support as well as the normal CAS authentication functionality.

Background
----------

[](#background)

Most websites at SFU that use CAS rely on the mod-auth-cas Apache module, which is available in a customized form for Apache 2.2 that also provides authorization support in the form of requirements for membership within a particular SFU mailing list.

Apache 2.2 is getting pretty long in the tooth, and the module doesn't work with other web servers, so we have created a purely PHP implementation of the CAS functionality that can be integrated with existing PHP applications with a minimal amount of work.

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

[](#installation)

**If you're using Composer:**

Just run:

> php composer.phar require sfu/php-cas

> php composer.phar update

> php composer.phar dump-autoload

and as long as you have set up the Composer autoloader correctly, you shouldn't have to do anything else.

**If you're not:**

Copy src/\*.php into your application in an appropriate location, and add a require() call into the application's header files to ensure the needed files are loaded (

Configuration
-------------

[](#configuration)

Within CASOptions.php is the SFU\\CASOptions class which you must edit for your environment. Defaults for the SFU environment are included, so for use at SFU no modification should be needed.

Options are defined as functions for versatility, and include:

1. ServerName() - returns the name of the CAS server
2. ServerPort() - returns the port to contact the CAS server on
3. ServerDirectory() - returns the toplevel path under which the CAS endpoints are found
4. URL() - returns the base URL for each CAS endpoint, assembled from the above functions
5. LoginURL() - relative path for the Login endpoint
6. LogoutURL() - relative path for the Logout endpoint
7. EmailDomain() - returns the domain name to append to usernames to create email addresses

Usage
-----

[](#usage)

Usage is simple, just add the following line to the top of any entry point or header file that will be loaded by a web browser:

```
SFU\CAS::requireLogin();

```

This will cause the CAS session to be checked, and if there's no currently valid session, the user will be redirected to the CAS server and then back to your app again. The second time around, there will be a GET parameter with ticket information that the CAS library will check against the CAS server, and if valid, it will create your session, logging you in.

**Mailing List Based Authorization**

Applicable to SFU CAS only. If you want to make it mandatory that a user be part of a particular maillist to get access, simply pass the maillist as the first parameter to requireLogin:

```
SFU\CAS::requireLogin("maillist-name");

```

**Alternate Return URL**

If you don't want to send the user back to the current endpoint, provide a different one as the second parameter to requireLogin:

```
SFU\CAS::requireLogin("maillist-name", "https://www.whatever.com/index.php");

```

**Logout**

To clear the session, call userLogout():

```
SFU\CAS::userLogout();

```

To actually log the user out of CAS, follow up with a redirector call:

```
SFU\CAS::redirectToLogout();

```

**Checking authentication without redirection**

In some contexts, you may not want to redirect the user when they aren't logged in, e.g. web-services style REST calls to your application. In this case, just call checkLoginStatus, optionally with a maillist parameter:

```
$logged_in = SFU\CAS::checkLoginStatus();
$logged_in_with_maillist = SFU\CAS::checkLoginStatus("maillist-name");

```

and you will receive a boolean that you can then handle yourself to return acceptable error output to your application.

Testing
-------

[](#testing)

Unit tests have not been created yet. In the meantime, you can do a quick test using the PHP development web server. From the tests/ folder, run:

```
php -S localhost:8000

```

and then fire up your web browser to  and you should be presented with your CAS login screen.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

4007d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d6f0af6e5d28b456795913b34a08df796bc17b1f16feb0e6e36b8596335148d1?d=identicon)[mike-sol](/maintainers/mike-sol)

---

Top Contributors

[![mike-sol](https://avatars.githubusercontent.com/u/6799314?v=4)](https://github.com/mike-sol "mike-sol (8 commits)")

---

Tags

casjasig

### Embed Badge

![Health badge](/badges/sfu-php-cas/health.svg)

```
[![Health](https://phpackages.com/badges/sfu-php-cas/health.svg)](https://phpackages.com/packages/sfu-php-cas)
```

###  Alternatives

[apereo/phpcas

Provides a simple API for authenticating users against a CAS server

8031.4M33](/packages/apereo-phpcas)[ecphp/cas-bundle

A bundle for Symfony, providing authentication against a Central Authentication Service (CAS) server.

48132.1k1](/packages/ecphp-cas-bundle)[xavrsl/cas

Add CAS server SSO authentication to Laravel 4 and 5

7736.8k](/packages/xavrsl-cas)[ecphp/cas-lib

CAS Lib, a standard library for CAS authentication.

18166.9k4](/packages/ecphp-cas-lib)[ecphp/eu-login-bundle

A bundle for Symfony, providing authentication against European Commission authentication service.

2848.1k](/packages/ecphp-eu-login-bundle)

PHPackages © 2026

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