apereo/phpcas
Apereo PHP CAS is a PHP client library for Central Authentication Service (CAS) single sign-on. It handles CAS login/logout flows, ticket validation, session management, and proxy support, with configurable endpoints for integrating CAS authentication into PHP apps.
apereo/phpcas package is a CAS (Central Authentication Service) client for PHP/Laravel, enabling seamless integration with CAS-based identity providers (e.g., universities, enterprises, or custom CAS servers). This aligns well with architectures requiring federated authentication (e.g., SaaS platforms, educational systems, or multi-tenant applications).Auth::attempt()) with CAS-based flows.CASMiddleware) that can be slotted into Laravel’s middleware pipeline (e.g., protected routes). Example:
Route::middleware(['web', 'cas'])->group(function () {
// CAS-protected routes
});
CasGuard) or as a custom provider for Auth::loginUsingId().file, database, redis) to be configured for CAS ticket validation. May need adjustments for distributed sessions (e.g., Redis with session:driver=redis).CasUserProvider).php-curl (for HTTP requests) and php-session (enabled by default).email, groups).composer require apereo/phpcas.config/cas.php with CAS server details./login → CAS redirect).CasUserProvider).Auth::shouldUse() for dynamic guard selection.'session' => ['driver' => 'redis'] in .env).web middleware (for sessions) or custom logic for APIs.league/oauth2-client).CAS_SERVER, CAS_VALIDATE_URL, and CAS_SERVICE in config/cas.php.'cas' => [
'client' => [
'casServer' => 'https://cas.example.com/cas',
'validateServer' => 'https://cas.example.com/cas',
'service' => 'https://app.example.com',
'authenticateUrl' => 'https://app.example.com/cas/login',
],
],
protected function registerCasMiddleware(): void
{
$this->app['router']->aliasMiddleware('cas', \Apereo\Cas\Client\Middleware\CASMiddleware::class);
}
CasUserProvider to resolve users from CAS attributes:
class CasUserProvider extends AbstractUserProvider
{
public function retrieveById($identifier)
{
// Fetch user from DB using CAS attributes
}
public function validateCredentials(User $user, array $credentials)
{
// Custom validation logic
}
}
Auth::login() or session-based auth).user->groups = $casAttributes['groups']).apereo/phpcas for breaking changes (e.g., CAS protocol updates).CAS_SERVER=https://cas.example.com
CAS_SERVICE=https://app.example.com
'cas' => [
'client' => [
'debug' => env('CAS_DEBUG', false),
],
],
How can I help you explore Laravel packages today?