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

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

norbertjurga/laravel-cas
========================

Apereo CAS Authentication for Laravel

v2.0.3(4y ago)020MITPHPPHP &gt;=7.3

Since Apr 9Pushed 4y agoCompare

[ Source](https://github.com/norbertjurga/laravel-cas)[ Packagist](https://packagist.org/packages/norbertjurga/laravel-cas)[ Docs](https://github.com/norbertjurga/laravel-cas)[ RSS](/packages/norbertjurga-laravel-cas/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (2)Versions (8)Used By (0)

Apereo CAS Authentication for Laravel
=====================================

[](#apereo-cas-authentication-for-laravel)

[![Donate](https://camo.githubusercontent.com/604e3db9c8751116b3f765aad0353ec7ded655bbe8aaacbc38d8c4a6b784b3ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e2e737667)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NU3XK7VXYTYKY)[![Latest Stable Version](https://camo.githubusercontent.com/d2751284a4ce3479cdf315fce6f441fc9b573f6618aed6f4d894aed7681db217/68747470733a2f2f706f7365722e707567782e6f72672f73656e747261736f66742f6c61726176656c2d6361732f762f737461626c65)](https://packagist.org/packages/sentrasoft/laravel-cas)[![Total Downloads](https://camo.githubusercontent.com/6331a30fbc24f5cf22219a9b3faad0f68cac0c0fa8552f49d8a606c0963d8963/68747470733a2f2f706f7365722e707567782e6f72672f73656e747261736f66742f6c61726176656c2d6361732f646f776e6c6f616473)](https://packagist.org/packages/sentrasoft/laravel-cas)[![Monthly Downloads](https://camo.githubusercontent.com/4776500afce1a88474adb4a22aacf5028eb65dc267bf4846d8bcab77829fd1c7/68747470733a2f2f706f7365722e707567782e6f72672f73656e747261736f66742f6c61726176656c2d6361732f642f6d6f6e74686c79)](https://packagist.org/packages/sentrasoft/laravel-cas)[![Latest Unstable Version](https://camo.githubusercontent.com/f5e915927211e331268628708f9fa798d9fe9be68845d81f6585581c46972dd8/68747470733a2f2f706f7365722e707567782e6f72672f73656e747261736f66742f6c61726176656c2d6361732f762f756e737461626c65)](https://packagist.org/packages/sentrasoft/laravel-cas)[![License](https://camo.githubusercontent.com/68caaae503feaf5ba1478581fe92d0c25efadbaf6e4a89acf738c44edea93ea7/68747470733a2f2f706f7365722e707567782e6f72672f73656e747261736f66742f6c61726176656c2d6361732f6c6963656e7365)](https://packagist.org/packages/sentrasoft/laravel-cas)

Easy Bring to CAS Authentication for Laravel

Install
-------

[](#install)

#### Via Composer

[](#via-composer)

```
$ composer require sentrasoft/laravel-cas
```

#### Via edit `composer.json`

[](#via-edit-composerjson)

```
"require": {
	"sentrasoft/laravel-cas": "dev-master"
}

```

Next, update Composer from the Terminal:

```
$ composer update
```

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

[](#configuration)

After updating composer, add the ServiceProvider to the providers array in `config/app.php`.

```
'providers' => array(
    .....
    Sentrasoft\Cas\CasServiceProvider::class,
);
```

Now add the alias in `config/app.php`.

```
'aliases' => array(
    ......
    'Cas' => Sentrasoft\Cas\Facades\Cas::class,
);
```

Add the middelware to your `Kernel.php` file or leverage your own:

```
'cas.auth'  => \Sentrasoft\Cas\Middleware\Authenticate::class,
'cas.guest' => \Sentrasoft\Cas\Middleware\RedirectIfAuthenticated::class,
```

Now publish the configuration `cas.php` file:

```
$ php artisan vendor:publish --provider="Sentrasoft\Cas\CasServiceProvider" --tag="config"
```

Add new environment variables below to your `.env`

```
CAS_HOSTNAME=cas.example.com
CAS_VALIDATION=https://cas.example.com/cas/p3/serviceValidate
CAS_VERSION=3.0
CAS_LOGOUT_URL=https://cas.example.com/cas/logout

```

> To see further configuration, please see and read the description for each configuration item [config/cas.php](src/Config/cas.php)

Route
-----

[](#route)

#### Authentication

[](#authentication)

Redirect the user to the authentication page for the provider.

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

#### Controller and Callback Route

[](#controller-and-callback-route)

You can create a new controller named `Auth\CasController`.

```
php artisan make:controller Auth\CasController
```

```
class CasController extends Controller
{
    /**
     * Obtain the user information from CAS.
     *
     * @return Illuminate\Http\RedirectResponse
     */
    public function callback()
    {
        // $username = Cas::getUser();
        // Here you can store the returned information in a local User model on your database (or storage).

        // This is particularly usefull in case of profile construction with roles and other details
        // e.g. Auth::login($local_user);

        return redirect()->route('home');
    }
}
```

When the authentication is performed the callback url is invoked. In that callback you can process the User and create a local entry in the database.

```
Route::get('/cas/callback', 'Auth\CasController@callback')->name('cas.callback');
```

#### Logout

[](#logout)

Logout of the CAS Session and redirect users.

```
Route::post('/cas/logout', [ 'middleware' => 'cas.auth', function() {
    cas()->logout();

    // You can also add @param string $url in param[0]
    cas()->logout(url('/'));

    // Or add @param string $service in param[1]
    cas()->logout('', url('/'));

}])->name('cas.logout');
```

> The `cas.auth` middleware is optional, but you will need to handle the error when a user tries to logout when they do not have a CAS Session.

> If the `CAS_LOGOUT_REDIRECT` configuration item in `.env` is added, the value is taken from that configuration. Or if nothing is configured, the value is taken based on the value you specified.

If you want to use *SLO (Single Logout)* (if the CAS server supports SLO), Your application must have a valid SSL and the CAS server must be able to send *HTTP POST* `/cas/logout` without having to verify `CsrfToken`. Therefore, you must change the `App\Http\Middleware\VerifyCsrfToken` file and exclude `/cas/logout` route.

```
/**
 * The URIs that should be excluded from CSRF verification.
 *
 * @var array
 */
protected $except = [
    //

    '/cas/logout',
];
```

You can check that it works by trying to send an *HTTP POST* via [cURL](https://en.wikipedia.org/wiki/CURL).

```
curl -X POST https://yourapp.com/cas/logout

```

Usage
-----

[](#usage)

#### Get User

[](#get-user)

To retrieve authenticated credentials.

> Not ID (integer), but given on the CAS login (username) form.

```
$uid = Cas::user()->id;
```

#### Get User Attributes

[](#get-user-attributes)

Get the attributes for for the currently connected user.

```
foreach (Cas::user()->getAttributes() as $key => $value) {
	...
}
```

#### Get User Attribute

[](#get-user-attribute)

Retrieve a specific attribute by key name. The attribute returned can be either a string or an array based on matches.

```
$value = Cas::user()->getAttribute('key');
```

Support Us
----------

[](#support-us)

[![Donate](https://camo.githubusercontent.com/604e3db9c8751116b3f765aad0353ec7ded655bbe8aaacbc38d8c4a6b784b3ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e2e737667)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NU3XK7VXYTYKY)

Help us to keep making awesome stuff. You don't have to be a developer to support our open source work. If you want to receive personal support, or just feel all warm and fuzzy inside from helping open source development, donations are very welcome. Thank you.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.1% 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 ~155 days

Recently: every ~186 days

Total

7

Last Release

1659d ago

Major Versions

v1.3.2 → v2.02021-10-25

PHP version history (2 changes)v1.3.0PHP &gt;=5.5.0

v2.0PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/eff0bb0b0632813aaeeebf1e161a5a9a6df38d826f62efd3571a5a2e5c54b046?d=identicon)[njurga](/maintainers/njurga)

---

Top Contributors

[![falestra](https://avatars.githubusercontent.com/u/12063138?v=4)](https://github.com/falestra "falestra (8 commits)")[![norbertjurga](https://avatars.githubusercontent.com/u/22997449?v=4)](https://github.com/norbertjurga "norbertjurga (4 commits)")[![shimeche](https://avatars.githubusercontent.com/u/1849666?v=4)](https://github.com/shimeche "shimeche (2 commits)")

---

Tags

laravelSSOcasphpCAS

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[xavrsl/cas

Add CAS server SSO authentication to Laravel 4 and 5

7736.8k](/packages/xavrsl-cas)

PHPackages © 2026

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