Symfony Security Core for Authorization Logic
Symfony Security Component - Core Library
At a glance
- What is it?
- symfony/security-core is a PHP library for building authorization decisions in Symfony applications while keeping user credential storage separate from access rules. It provides access decision managers, voters, role hierarchy support, and token-based decisions.
- Who is it for?
- Adopt symfony/security-core when your Symfony application needs reusable token-based authorization decisions and role hierarchy checks. Do not treat it as a complete authentication system or as a replacement for the user provider that stores and retrieves credentials.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository received new commits within the last day.
- What is it written in?
- Mainly PHP, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.
Star history
- symfony/security-core1,879 ★ · +0
| Repository | 2026-10-16 | 2026-10-23 |
|---|---|---|
| symfony/security-core | 1.9k | 1.9k |
0 Stars in the last 7 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Why Symfony Security Core Exists
Symfony Security Core solves the separation problem between application authorization logic and the user provider that holds user credentials. The README describes the component as infrastructure for sophisticated authorization systems. That boundary matters because an access rule should not need to know how a user record is stored, loaded, or authenticated. A user provider can supply the user object, while the core library evaluates whether that user is allowed to perform a requested action.
The intended audience is PHP developers working within Symfony who need authorization behavior that can be represented through roles, authentication state, and voting rules. The repository is a component rather than a standalone application. Its default branch is 8.2, and the package is distributed under the MIT license. The README points to Symfony’s security documentation for broader integration details rather than presenting this repository as a complete application skeleton.
The central design choice is useful when authorization rules need to change independently of credential storage. It also leaves room for multiple voters to participate in one decision. The trade-off is that the library does not decide where users come from. The example passes a user object into `UsernamePasswordToken`, so the application remains responsible for constructing that user and its roles.
Access Decision Manager and Voter Flow
The example shows the package’s main authorization path. An `AccessDecisionManager` receives a collection of voters. The application then calls `decide` with an authentication token and the attribute it wants to enforce, such as `ROLE_ADMIN`. The manager returns a Boolean decision that the application can use to allow or reject the operation.
Three voters appear in the README example. `AuthenticatedVoter` evaluates authentication state through `AuthenticationTrustResolver`. `RoleVoter` evaluates roles carried by the token. `RoleHierarchyVoter` applies a `RoleHierarchy` so that a higher role can imply a lower one. In the example, `ROLE_ADMIN` maps to `ROLE_USER`, allowing the hierarchy to express inherited permissions without duplicating every lower role in the user object.
The token is the bridge between authentication and authorization. `UsernamePasswordToken` contains the user object, the authentication firewall name `main`, and the user roles. The authorization code receives that token rather than querying a credential store directly. This is the concrete separation described by the project: authentication-related user data and authorization decisions meet at the token boundary.
This architecture is extensible, but the repository example does not explain voter strategy configuration, voting behavior when voters disagree, caching, or audit logging. Those details should be checked in the Symfony security documentation before relying on a particular access-control policy.
Installing symfony/security-core and Making a Decision
The README gives the following Composer installation command. It installs the Symfony Security Core package into a PHP project.
composer require symfony/security-coreAfter installation, the following example creates an access decision manager, defines a role hierarchy, constructs a username-password token, and checks the `ROLE_ADMIN` attribute. The user object is represented by `\App\Entity\User(...)` in the README, so an application must replace that placeholder with its actual entity or user implementation.
$accessDecisionManager = new AccessDecisionManager([
new AuthenticatedVoter(new AuthenticationTrustResolver()),
new RoleVoter(),
new RoleHierarchyVoter(new RoleHierarchy([
'ROLE_ADMIN' => ['ROLE_USER'],
]))
]);The README continues with token construction and the decision call:
$token = new UsernamePasswordToken($user, 'main', $user->getRoles());
if (!$accessDecisionManager->decide($token, ['ROLE_ADMIN'])) {
throw new AccessDeniedException();
}For a first real use, the application must have a user object with a `getRoles()` method, import the Symfony classes shown in the README, and invoke the decision at the point where access to an operation is enforced. The repository does not provide a runnable application, database schema, route, or authentication configuration in its README. The linked Symfony security documentation is the stated place for those integration details.
Role Hierarchies and Token Boundaries
Role hierarchy support is the clearest concrete convenience in the README example. The `RoleHierarchy` configuration declares that `ROLE_ADMIN` includes `ROLE_USER`. `RoleHierarchyVoter` then participates in the same decision as the ordinary role voter. This lets an application define a role model where administrative access implies user-level access.
That model is compact, but it also creates a dependency on role naming and token contents. If `$user->getRoles()` does not contain the expected roles, the decision is based on incomplete information. If the token’s authentication name does not match the application’s firewall context, it should not be assumed that the token represents the current request. The README uses `main` as that name, but it does not document the configuration required to establish it.
The library also separates trusted authentication information through `AuthenticationTrustResolver`. The example passes a fresh resolver to `AuthenticatedVoter`, but it does not show how authentication providers, firewalls, or token storage are configured. Therefore, this package should be evaluated as an authorization building block, not as a turnkey login solution. The application must connect its authentication flow to the token and then enforce the manager’s result in the relevant code path.
What Security Core Does Not Document
The repository is not a complete security product, and the README does not document the surrounding responsibilities that commonly affect an authorization decision. It does not show password verification, login forms, session handling, CSRF protection, rate limiting, user persistence, token invalidation, or recovery of failed authentication. Those omissions do not prove that the surrounding Symfony components lack such features. They mean the README does not establish them as behavior of `symfony/security-core`.
There is also no documented answer for how conflicting voters should be combined in this example, whether decisions can be cached, or how authorization events are recorded. The visible code only constructs an `AccessDecisionManager` and calls `decide`. An application that requires a particular strategy, denial behavior, or audit trail must verify those settings in the relevant Symfony documentation and its own integration code.
The repository’s directory layout includes `Authentication/`, `Authorization/`, `Role/`, `User/`, `Validator/`, `Exception/`, `Event/`, and related directories. Based on that layout, the package covers more than the single voter example, but the README does not define the behavior or configuration of every directory. Treating the component as the entire security boundary would therefore be a mistake.
Maintenance, Releases, and the Alternative Design
The repository is not archived. Its last push was on 2026-10-15, and the recent releases listed include `v5.4.54` on 2026-10-15, `v8.1.9` on 2026-10-14, and `v7.4.21` on 2026-10-14. Those release branches indicate that version-specific maintenance activity is part of the repository’s published history. The README does not provide a compatibility matrix, upgrade procedure, or changelog guidance for moving between branches.
The package is licensed under MIT. That identifies the repository’s stated license, but it is not a guarantee that every dependency or surrounding Symfony configuration uses the same terms. The README does not provide legal interpretation or dependency licensing details, so those must be checked separately when assembling an application.
A real alternative is to implement authorization checks directly in application code, comparing roles or permissions from the current user without a dedicated voter-based decision manager. That approach can be simpler for a small application with a few fixed checks, but it couples authorization rules to application services and makes a consistent decision layer harder to reuse. Symfony Security Core takes the opposite approach: application code supplies a token and attribute, while configured voters decide whether the token satisfies that attribute. The package is the better fit when reusable authorization structure matters; direct checks remain reasonable when the application’s policy is small and explicitly owned by one code path.
Editorial conclusion
Adopt symfony/security-core when your Symfony application needs reusable token-based authorization decisions and role hierarchy checks. Do not treat it as a complete authentication system or as a replacement for the user provider that stores and retrieves credentials. Verify first that your user object exposes roles, your token represents the authenticated request state, and your voter set matches the permissions your application must enforce.
Frequently asked questions
What does symfony/security-core do?
It provides infrastructure for authorization systems that separate authorization logic from user providers holding user credentials. Its README shows access decisions based on authentication state, roles, and role hierarchies.
How do I install symfony/security-core?
The README specifies `composer require symfony/security-core`. The repository is a Symfony component, so the surrounding application also needs a compatible PHP and Symfony environment.
How does the AccessDecisionManager example work?
It receives voters, then evaluates a `UsernamePasswordToken` against an attribute such as `ROLE_ADMIN`. The example throws `AccessDeniedException` when `decide` returns false.
Does symfony/security-core provide the user provider?
The README describes Security Core as separating authorization logic from user providers that hold credentials. The example accepts a user object and calls its roles, so this repository does not present credential storage as the responsibility of the authorization code.
Can role hierarchy represent inherited permissions?
Yes, according to the README example, `ROLE_ADMIN` is configured to imply `ROLE_USER` through `RoleHierarchy`. This is implemented in the example through `RoleHierarchyVoter`.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/symfony-security-core)Star history chart for your README
[](https://hysenlabs.com/projects/symfony-security-core)Was this useful?