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

ActiveLibrary

hanovate/cas
============

Adds CAS support to Laravel 7.x or 8.x

v3.1.3(5y ago)02121MITPHPPHP &gt;=7.2.0

Since Apr 28Pushed 5y agoCompare

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

READMEChangelogDependencies (3)Versions (25)Used By (0)

CAS client for Laravel 7|8
==========================

[](#cas-client-for-laravel-78)

This is a fork of subfission/cas updated to utilize Laravel's session management methods.

Refer to subfission/cas documentation for more details. This includes installation and usage procedures.

Simple CAS Authentication for Laravel 7.x and 8.x.

Tested on Laravel 7.6.1 as of 2020-04-15, Laravel 8.18.1 as of 2020-12-10

INSTALLATION
------------

[](#installation)

1. Install the package inside your project root folder:
-------------------------------------------------------

[](#1-install-the-package-inside-your-project-root-folder)

```
$ composer require hanovate/cas

```

2. Add the following two lines to your ./app/Http/Kernel.php
------------------------------------------------------------

[](#2-add-the-following-two-lines-to-your-apphttpkernelphp)

```
    protected $routeMiddleware = [
        ...
        'cas.auth' => \Hanovate\Cas\Middleware\CASAuth::class,
        'cas.guest' => \Hanovate\Cas\Middleware\RedirectCASAuthenticated::class,
        ...
    }

```

3. Add the following environment parameters in your ./.env
----------------------------------------------------------

[](#3-add-the-following-environment-parameters-in-your-env)

```
CAS_HOSTNAME=login.myschool.edu
CAS_REAL_HOSTS=login.myschool.edu
CAS_LOGOUT_URL=https://login.myschool.edu/cas/logout
CAS_REDIRECT_PATH=https://myapp.myschool.edu/main-for-logged-in-user
CAS_CONTROL_SESSIONS=false
CAS_ENABLE_SAML=true
CAS_VERSION=3.0

```

CAS\_DEBUG, CAS\_VERBOSE\_ERRORS can be set to true if you want to see more detailed error message.

CAS\_VERSION should be set to the CAS protocol version, not the CAS server version.

CAS\_REDIRECT\_PATH is the default address to go after the user is authenticated on the CAS server.

4. Run 'artisan vendor:publish' command and select ''cas''
----------------------------------------------------------

[](#4-run-artisan-vendorpublish-command-and-select-cas)

```
$ ./artisan vendor:publish --tag=cas
Copied File [/vendor/hanovate/cas/src/config/config.php] To [/config/cas.php]
Publishing complete.
```

USAGE
-----

[](#usage)

In order to define Gates inside ./app/Http/Providers/AuthServiceProvider.php, add the following lines:

```
...
use Illuminate\Support\Facades\Auth;
use App\Auth\Guards\CasGuard;
...

    ...
    public function boot()
    {
        $this->registerPolicies();

        Auth::extend('cas',function($app, $name, array $config) {
            return new CasGuard();
        });

        Gate::define('request',function($user) {
            return true;
        });
    }

...

```

In your route file (e.g. ./routes/web.php), the web middleware cas.auth can be used for the simple authentication.

```
...

Route::get('/',function() {
    if (cas()->isAuthenticated()) {
        echo 'authenticated';
        echo 'click here to go to home';
        echo 'user: '.cas()->user().'';
        echo 'logout';
    } else {
        echo 'not authenticated';
        echo 'login';
    }
});

Route::get('/login',function() {
    cas()->authenticate();
})->name('main.login');

Route::middleware(['cas.auth'])->group(function() {
    Route::get('/main', function() {
        echo 'This is a main home page';
        echo 'user: '.cas()->user().'';
        echo 'logout';
    })->name('main.home');

    Route::get('/auth/logout',function() {
        return cas()->logout(null,'https://auth1.unm.edu/');
    })->name('main.logout');
});
...

```

LICENSE
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2017 Zach Jetson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 64.2% 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

Every ~94 days

Total

23

Last Release

1959d ago

Major Versions

v1.1.0 → v2.0.02016-01-21

v2.1.1 → v3.0.02019-12-06

PHP version history (2 changes)1.0.0PHP &gt;=5.5.0

v3.0.0PHP &gt;=7.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3bd8016c2857029d23daa3c5596ed6acefcc94be3bfdb29c24b77874ccb63cbd?d=identicon)[clayjar](/maintainers/clayjar)

---

Top Contributors

[![subfission](https://avatars.githubusercontent.com/u/8132423?v=4)](https://github.com/subfission "subfission (43 commits)")[![clayjar](https://avatars.githubusercontent.com/u/1398837?v=4)](https://github.com/clayjar "clayjar (17 commits)")[![ganlvtech](https://avatars.githubusercontent.com/u/8651285?v=4)](https://github.com/ganlvtech "ganlvtech (2 commits)")[![uyab](https://avatars.githubusercontent.com/u/149716?v=4)](https://github.com/uyab "uyab (1 commits)")[![abejenaru](https://avatars.githubusercontent.com/u/1703377?v=4)](https://github.com/abejenaru "abejenaru (1 commits)")[![wudi](https://avatars.githubusercontent.com/u/3753615?v=4)](https://github.com/wudi "wudi (1 commits)")[![defrox](https://avatars.githubusercontent.com/u/5087774?v=4)](https://github.com/defrox "defrox (1 commits)")[![flartet](https://avatars.githubusercontent.com/u/1814609?v=4)](https://github.com/flartet "flartet (1 commits)")

---

Tags

laravellaravel 7laravel 8SSOcasphpCAS

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[xavrsl/cas

Add CAS server SSO authentication to Laravel 4 and 5

7736.8k](/packages/xavrsl-cas)[efficiently/jquery-laravel

This package provides jQuery and the jQuery-ujs driver for your Laravel &gt;= 6 application.

1311.0k1](/packages/efficiently-jquery-laravel)[itsmurumba/laravel-mpesa

Laravel Package for Mpesa Daraja API

191.6k](/packages/itsmurumba-laravel-mpesa)

PHPackages © 2026

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