jasig/phpcas
phpCAS is a PHP client library for CAS (Central Authentication Service). It helps PHP apps authenticate users via a CAS server, handling login/logout redirects, validating tickets, and managing sessions with configurable SSL and server settings.
jasig/phpcas package is a CAS (Central Authentication Service) client for PHP/Laravel, enabling seamless integration with CAS-based identity providers (e.g., universities, enterprise SSO). It fits well in architectures requiring federated authentication (e.g., SaaS platforms, academic systems, or multi-tenant applications).Authenticate middleware or a custom CASGuard to intercept requests and redirect to CAS.auth()->user() may need CAS-specific overrides).session() helper can bridge this, but may require custom drivers.phpcas in a non-production Laravel app with a test CAS server.auth()->user() reflects CAS claims).auth()->onceUsingId() or custom guards.laravel/sanctum, spatie/laravel-permission).// config/services.php
'cas' => [
'client' => [
'host' => env('CAS_HOST', 'https://cas.example.com'),
'path' => env('CAS_PATH', '/cas'),
'secure' => env('CAS_SECURE', true),
],
'service' => env('APP_URL'),
];
// app/Http/Middleware/AuthenticateWithCas.php
public function handle(Request $request, Closure $next) {
$cas = new \Jasig\phpCAS();
$cas->setNoCasServerValidation();
$cas->authenticate();
// Map CAS attributes to Laravel user
return $next($request);
}
// app/Http/Kernel.php
protected $routeMiddleware = [
'cas.auth' => \App\Http\Middleware\AuthenticateWithCas::class,
];
Route::middleware(['cas.auth'])->group(function () {
// Protected routes
});
Illuminate\Contracts\Auth\UserProvider to fetch users from CAS attributes or a local DB.jasig/phpcas for breaking changes (e.g., PHP 9.0 support).composer.json to avoid surprises.Log::debug() to trace authentication issues.service URL).uid but Laravel expects email).php artisan tinker) to inspect $request->user().| Failure Scenario | Impact | Mitigation |
|---|---|---|
| CAS server downtime | Users locked out | Local auth fallback or static maintenance page. |
| Invalid CAS ticket | Authentication failures | Rate-limit retries; log failed tickets. |
| Session hijacking | Unauthorized access | Enforce HTTPS; use secure cookies. |
| Attribute mapping errors | User data corruption | Validate CAS attributes against schema. |
| PHP/CAS version incompatibility | Runtime errors | Test with exact PHP/CAS versions in CI. |
How can I help you explore Laravel packages today?