easycorp/easy-security-bundle
DEPRECATED/UNMAINTAINED: Symfony 3.4 includes similar features. EasySecurityBundle adds a “security” service with shortcuts for common Symfony Security tasks (get current user, check roles, login errors) to reduce complexity and verbosity.
@security service injection).isFullyAuthenticated(), login()) that simplify common security operations.Illuminate\Auth) is conceptually similar but not identical. Key mappings:
TokenStorage → Laravel’s Auth::user() or Auth::guard()->user().AuthorizationChecker → Laravel’s Gate or Policy classes.Security service with a Laravel service provider that mirrors its API.Security::getUser()) or helper traits to bridge gaps.symfony/security-core). May conflict with Laravel’s composer constraints or PSR compliance.replace or custom namespace aliases.Kernel, EventDispatcher, and HttpFoundation—Laravel uses Illuminate\Foundation.Auth facade).addClassesToCompile).isRemembered()) map to Laravel’s auth system.Auth, Gate, and Policy systems may suffice. Does this bundle offer unique value (e.g., impersonation, password encoding) not covered natively?spatie/laravel-permission (for role/permission management).laravel/breeze/laravel/jetstream (for auth scaffolding).EasySecurity service.Security facade (e.g., Security::isGranted()).security-core (~5.4MB). May conflict with Laravel’s illuminate/auth.replace or custom aliases to avoid conflicts.Security class to Laravel’s container.TokenStorage with Laravel’s Auth::guard().AuthorizationChecker with Gate::forUser().ServiceProvider conventions.// app/Providers/EasySecurityServiceProvider.php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use EasyCorp\Bundle\EasySecurityBundle\Security\Security;
class EasySecurityServiceProvider extends ServiceProvider {
public function register() {
$this->app->singleton('security', function ($app) {
return new Security(
$app['auth'], // Laravel Auth manager
$app['gate'] // Laravel Gate
);
});
}
}
getUser() → Auth::user().isGranted('ROLE_ADMIN') → Gate::forUser()->allows('admin').login($user) → Auth::login($user).| Feature | Symfony Native | Laravel Native | Bundle’s Approach | Laravel Adaptation Needed? |
|---|---|---|---|---|
| User retrieval | TokenStorage |
Auth::user() |
getUser() |
✅ Use Auth::user() |
| Role checking | AuthorizationChecker |
Gate/Policy |
isGranted() |
✅ Map to Gate::allows() |
| Login | Manual token creation | Auth::login() |
login($user) |
✅ Use Auth::login() |
| Password encoding | UserChecker |
Hash facade |
encodePassword() |
✅ Use Hash::make() |
| Impersonation | Built-in | No native | getImpersonatingUser() |
❌ Custom logic needed |
Gate::forUser()->check() calls with security->isGranted().login() and impersonation for internal tools.isFullyAuthenticated).CHANGELOG.md for Laravel-specific changes.easy-security-bundle laravel).Gate/Policy, ensure caching is configured (Laravel’s Gate::shouldCache()).How can I help you explore Laravel packages today?