1. Go to this page and download the library: Download sentrasoft/laravel-cas library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
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');
}
}
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 URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
'/cas/logout',
];
$uid = Cas::user()->id;
foreach (Cas::user()->getAttributes() as $key => $value) {
...
}