alexandret/phpcas-guard-bundle
HttpKernel or a custom adapter layer).jasig/phpcas (a mature PHP-CAS library), ensuring standard CAS 1.0/2.0/3.0 compatibility. This aligns with Laravel’s need for SSO/SAML/OAuth alternatives for enterprise authentication.AuthenticatesUsers trait or a custom Guard-like service. However, Laravel’s provider/contract system may require additional abstraction.Security component, DependencyInjection, and Config systems. Laravel’s service container and configuration (e.g., .env) differ significantly.kernel.events) is not natively available in Laravel, requiring custom event listeners or a wrapper (e.g., Laravel’s Events facade).Routing component is not directly usable; Laravel’s router would need to handle CAS-specific routes (/cas/login, /cas/validate).phpcasguard.cas_authenticator (e.g., CasGuardAuthenticator service).cas_guard.yaml to Laravel’s .env and config/cas.php.Firewall with Laravel’s auth middleware (auth:cas).UserProvider, TokenStorage).phpcas Directly: If integration proves too cumbersome, use jasig/phpcas standalone with a custom Laravel authenticator.spatie/laravel-cas) that may offer Laravel-native solutions.onelogin/php-saml) be more maintainable?spatie/laravel-cas) that avoid Symfony dependencies?jasig/phpcas) is PHP-agnostic. Integration requires:
CasGuardBundle services as Laravel providers/services./cas/validate) to Laravel routes using middleware..env to inject CAS server settings (e.g., CAS_HOSTNAME).symfony/http-foundation).illuminate/auth for user provider integration.spatie/laravel-ignition for debugging CAS-specific errors.Phase 1: Proof of Concept
phpcas: Use jasig/phpcas directly in a Laravel service to validate CAS authentication logic.phpcas:
use Jasig\phpcas\CAS;
CAS::client(CAS::SERVICE_VERIFY, 'https://app.example.com/cas', 443, '/cas', false);
if (CAS::isAuthenticated()) {
// Proceed with Laravel auth.
}
Phase 2: Bundle Integration
namespace App\Providers;
use AlexandreT\Bundle\CasGuardBundle\CasGuardBundle;
use Symfony\Component\HttpKernel\KernelInterface;
class CasGuardServiceProvider extends ServiceProvider {
public function register() {
$this->app->singleton('cas.guard', function () {
$bundle = new CasGuardBundle();
return $bundle->getContainer()->get('phpcasguard.cas_authenticator');
});
}
}
// config/cas.php
return [
'hostname' => env('CAS_HOSTNAME'),
'debug' => env('CAS_DEBUG', false),
];
// app/Http/Middleware/CasAuthenticate.php
public function handle($request, Closure $next) {
if (!$this->casGuard->isAuthenticated()) {
return redirect()->to('https://' . config('cas.hostname') . '/login');
}
return $next($request);
}
Phase 3: Full Integration
CasUserProvider to fetch user data from CAS attributes.AuthenticatesUsers trait to use CAS tokens./cas/logout?url={redirect}).Events::dispatch().symfony/security-guard, symfony/config, symfony/dependency-injection.illuminate/config and illuminate/container as proxies.jasig/phpcas:~1.3. Ensure Laravel’s composer.json pins this version to avoid conflicts.symfony/dependency-injection as a drop-in.phpcas standalone for validation.CasGuardServiceProvider.Auth facade.jasig/phpcas is abandoned (last update: 2017). Security patches may require manual fixes.security-guard) are deprecated in Symfony 6+. Future Laravel upgrades may break compatibility.cas_guard.yaml must be manually synced with Laravel’s .env/config/cas.php.How can I help you explore Laravel packages today?