Skip to content

The Security Component

Warning: You are browsing the documentation for Symfony 2.x, which is no longer maintained.

Read the updated version of this page for Symfony 7.1 (the current stable version).

The Security component provides a complete security system for your web application. It ships with facilities for authenticating using HTTP basic or digest authentication, interactive form login or X.509 certificate login, but also allows you to implement your own authentication strategies. Furthermore, the component provides ways to authorize authenticated users based on their roles, and it contains an advanced ACL system.

Installation

1
$ composer require symfony/security

Alternatively, you can clone the https://github.com/symfony/security repository.

Note

If you install this component outside of a Symfony application, you must require the vendor/autoload.php file in your code to enable the class autoloading mechanism provided by Composer. Read this article for more details.

The Security component is divided into four smaller sub-components which can be used separately:

symfony/security-core
It provides all the common security features, from authentication to authorization and from encoding passwords to loading users.
symfony/security-http
It integrates the core sub-component with the HTTP protocol to handle HTTP requests and responses.
symfony/security-csrf
It provides protection against CSRF attacks.
symfony/security-acl
It provides a fine grained permissions mechanism based on Access Control Lists.

See also

This article explains how to use the Security features as an independent component in any PHP application. Read the Security article to learn about how to use it in Symfony applications.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version