How to integrate phpCAS in Laravel

I would like to share you how to integrate phpCAS in Laravel. As you know, Jasig CAS is a Single-Sign-On System. If you want to connect to Jasig CAS from your system (that is wrote by PHP), you use phpCAS Library

Work hard in Silence, Let Success make the noise

Work hard in Silence, Let Success make the noise

To know how to install a Jasig CAS server, please see:  https://sonnguyen.ws/install-jasig-cas-ubuntu-14-04/

Step 1:  Download phpCAS Library and locate it in app/library directory

Step 2: Create CAS Authentication Provider

We create file CasAuthProvider.php

Add source code to file:

Please make note that, you have to add  cas_host, cas_context, cas_port to app/config/app.php file

Step 3: Adding new provider to Laravel

Edit app/start/global.php file by adding code:

Step 4: Adding phpCAS library, new provider to Laravel Autoload

Open composer.json located at Laravel Root Directory and add app/library/phpCAS, app/cas:

Dump new Laravel Autoload file:

Step 5: Finally, create route and controller for login action

In app/routes.php file add:

In app/controllers/Admin.php add: