The Security component provides a complete security system for your web application. It ships with facilities for authenticating using HTTP basic 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.
The Security component is divided into several smaller sub-components which can be used separately:
- It provides all the common security features, from authentication to authorization and from encoding passwords to loading users.
- It integrates the core sub-component with the HTTP protocol to handle HTTP requests and responses.
- It provides protection against CSRF attacks.
- It brings many layers of authentication together, allowing the creation of complex authentication systems.
You can install each of them separately in your project:
1 2 3 4
$ composer require symfony/security-core $ composer require symfony/security-http $ composer require symfony/security-csrf $ composer require symfony/security-guard
If you install this component outside of a Symfony application, you must
vendor/autoload.php file in your code to enable the class
autoloading mechanism provided by Composer. Read
this article for more details.
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.
- The Firewall and Authorization
- Securely Generating Random Values
- How Does the Security access_control Work?
- How to Customize Access Denied Responses
- How to Implement CSRF Protection
- How to Write a Custom Authenticator
- The Entry Point: Helping Users Start Authentication
- Security: Complex Access Controls with Expressions
- How to Restrict Firewalls to a Request
- How to Force HTTPS or HTTP for different URLs
- Customizing the Form Login Authenticator Responses
- How to Impersonate a User
- Authenticating against an LDAP server
- How to use Passwordless Login Link Authentication
- Password Hashing and Verification
- How to Add "Remember Me" Login Functionality
- How to Create and Enable Custom User Checkers
- User Providers
- How to Use Voters to Check User Permissions
- Security Configuration Reference (SecurityBundle)