Installation
Versions
Version 1.0 requires PHP 5.5.9+., (*1)
Laravel 5.1
To install this package pull it in through Composer., (*2)
composer require csi-uksw/laravel-cas
After Composer is done, you need to tell your application to use the CAS service provider., (*3)
Open config/app.php
and add the service provider, (*4)
CSI_UKSW\Laravel\CAS\CASServiceProvider::class
, (*5)
after, (*6)
Illuminate\Auth\AuthServiceProvider::class
, (*7)
As well the Facade :, (*8)
'CAS' => CSI_UKSW\Laravel\CAS\Facades\CAS::class
, (*9)
Configuration
Basic
To set up your CAS for connections you have to publish CAS config. This will provide all the configuration values for your connection., (*10)
php artisan vendor:publish --provider="CSI_UKSW\Laravel\CAS\CASServiceProvider"
After that please edit your app/cas.php
. Using the .env
file will allow you to have different environments without even touching the app/cas.php
config file., (*11)
Middleware
Optionally you can use provided Auth Middleware., (*12)
After publishing please edit your app/Http/Kernel.php
, (*13)
protected $routeMiddleware = [
'auth.cas' => \CSI_UKSW\Laravel\CAS\Http\Middleware\CASAuthMiddleware::class
];
Usage
Authenticate:, (*14)
CAS::authenticate()
, (*15)
Logout:, (*16)
CAS::logout()
, (*17)
Get username:, (*18)
CAS::getUser()
, (*19)
Get user attributes:, (*20)
CAS::getAttributes()
, (*21)
Check if is authenticated:, (*22)
CAS::isAuthenticated()
, (*23)
Route middleware:, (*24)
Route::group(['middleware' => 'auth.cas'], function () {
get('cas', function(){
echo 'authorized only';
});
});