PHP code example of lyn-huang / laravel-cas-client

1. Go to this page and download the library: Download lyn-huang/laravel-cas-client 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/ */

    

lyn-huang / laravel-cas-client example snippets


use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use LynHuang\LaravelCasClient\Services\CasManager;

Route::get('/cas/callback', function (Request $request, CasManager $casManager) {
    $result = $casManager->handleCallback($request->query('ticket'));

    // ↓ 在这里由业务方自行决定如何落地登录态
    // Auth::loginUsingId($result['resolved_user']['id']);

    return response()->json($result);
});

Route::get('/profile', function () {
    return '受保护内容';
})->middleware('cas.auth');