The Security Component

The Security component provides a complete security system for your webapplication. It ships with facilities for authenticating using HTTP basicauthentication, interactive form login or X.509 certificate login, but alsoallows you to implement your own authentication strategies. Furthermore, thecomponent provides ways to authorize authenticated users based on theirroles.

Installation

  1. $ composer require symfony/security

Note

If you install this component outside of a Symfony application, you mustrequire the vendor/autoload.php file in your code to enable the classautoloading mechanism provided by Composer. Readthis article for more details.

The Security component is divided into several smaller sub-components which canbe used separately:

  • symfony/security-core
  • It provides all the common security features, from authentication toauthorization and from encoding passwords to loading users.
  • symfony/security-http
  • It integrates the core sub-component with the HTTP protocol to handle HTTPrequests and responses.
  • symfony/security-csrf
  • It provides protection against CSRF attacks.
  • symfony/security-guard
  • It brings many layers of authentication together, allowing the creationof complex authentication systems.

This article explains how to use the Security features as an independentcomponent in any PHP application. Read the Security article to learnabout how to use it in Symfony applications.

Learn More