Skip to content
Zach :(){ :|: & } edited this page Oct 28, 2017 · 6 revisions

Basic Usage Example:

Via Routes Login

get('/auth/login', function(){
    cas()->authenticate();
});

You would now have access to cas()->user(), usually collected by middleware or custom authenticating guard.

Via Middleware Login

public function handle($request, Closure $next)
{
    if( ! cas()->checkAuthentication() )
    {
        if ($request->ajax()) {
            return response('Unauthorized.', 401);
        }
        cas()->authenticate();
    }
    session()->put('cas_user', cas()->user() );
    return $next($request);
}

You would now have access to the cas user via session or by cas()->user().

Logout From route

get('/auth/logout', [
    'middleware' => 'cas.auth', 
    function(){ 
        cas()->logout(); 
    }
]);

Note: 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.

Clone this wiki locally