Symfony SecurityBundle
Symfony's full-stack authentication and authorization layer, configuring firewalls, authenticators, and access rules from YAML
Repository Health
Technical Analysis
SecurityBundle wires Symfony’s standalone Security components (security-core, security-http, security-csrf) into the full-stack framework’s configuration system, letting applications declare firewalls, authenticators, user providers, and access-control rules declaratively in security.yaml instead of assembling the underlying services by hand. It handles the entire authentication lifecycle — login forms, JSON login, HTTP Basic, remember-me cookies, login links — plus authorization via role hierarchies, voters, and access-control rules matched against request attributes.
Because it governs which requests reach which controllers under what identity, SecurityBundle is effectively app-wide infrastructure: every route in a Symfony project passes through the firewall map this bundle configures, making it one of the framework’s most structurally significant bundles rather than an optional add-on library.
What You Get
- Firewall configuration (
FirewallMap,FirewallContext) mapping URL patterns to distinct authentication strategies - Built-in authenticators for form login, JSON login, HTTP Basic, remember-me, and passwordless login links
- Role-hierarchy and voter-based authorization checked via
is_granted()and the#[IsGranted]attribute - A
DataCollectorintegration surfacing firewall/authentication details in the Symfony profiler for debugging - Console commands for debugging firewalls, generating password hashes, and inspecting configured user checks
Common Use Cases
- Protecting an entire application behind login with role-based access control defined once in
security.yaml - Running separate authentication strategies for a public API (stateless JSON login) and an admin panel (session-based form login) in the same app via multiple firewalls
- Implementing passwordless login links or remember-me cookies without hand-writing token-generation and validation logic
- Writing custom voters for fine-grained, object-level authorization (e.g. “can this user edit this specific post”)
Under The Hood
Architecture FirewallMap.php and FirewallContext.php route each incoming request to the correct firewall configuration (FirewallConfig.php), which in turn selects authenticators, user providers, and event listeners registered under EventListener/; DependencyInjection/ compiles the security.yaml config tree into container definitions, while Security.php exposes the runtime facade (isGranted(), getUser()) that application code calls.
Tech Stack PHP 8.4+ bundle requiring symfony/security-core, symfony/security-csrf, symfony/http-kernel, symfony/http-foundation, symfony/password-hasher, symfony/clock, symfony/config, and symfony/dependency-injection — it is an integration layer over several lower-level Security components rather than implementing authentication logic itself.
Code Quality A large Tests/ directory covering DependencyInjection, EventListener, Routing, and LoginLink reflects the bundle’s role securing production traffic; DataCollector/ and Debug/ namespaces exist specifically to make misconfiguration visible during development, a strong signal of attention to operator experience.
API Design Most day-to-day usage is declarative YAML configuration plus a small Security facade and #[IsGranted] attribute, but understanding the full firewall/authenticator/voter/user-provider model requires real ramp-up — this is consistently cited as one of the steeper parts of learning Symfony, even though the payoff is a centrally auditable security policy.
Used by 3 apps in this directory
Kimai
Invoicing Finance · Project Management
Professional open-source time tracking with invoicing, multi-user support, SAML/LDAP auth, and a full REST API—self-host it or use the cloud.
Mautic
Automation · Marketing · Ecommerce
The world's largest open source marketing automation platform — own your data, run multi-channel campaigns, and escape vendor lock-in forever.
wallabag
Bookmarks Archiving
Self-hosted read-it-later app that saves clean, ad-free articles from any webpage for distraction-free reading across all your devices.