β

Easier Authentication with Guard in Symfony 3

SitePoint » PHP 304 阅读

The Symfony2 security system is a complex part of the framework, one that is difficult to understand and work with for many people. It is very powerful and flexible, however not the most straightforward. For an example of custom authentication system, check out my previous article that integrates Symfony with the UserApp service.

Lock image

With the release of version 2.8 (and the much awaited version 3), a new component was accepted into the Symfony framework: Guard . The purpose of this component is to integrate with the security system and provide a very easy way for creating custom authentications. It exposes a single interface, whose methods take you from the beginning to the end of the authentication chain: logical and all grouped together.

In this article, we are going to create a simple form authentication that requires a user to be logged in and have the ROLE_ADMIN role for each page. The original way of building a form authentication can still be used, but we will use Guard to illustrate its simplicity. You can then apply the same concept to any kind of authentication (token, social media, etc).

If you want to follow along in your own IDE, you can clone this repository which contains our Symfony application with Guard for authentication. So, let’s begin.

Continue reading % Easier Authentication with Guard in Symfony 3 %

作者:SitePoint » PHP
Learn CSS | HTML5 | JavaScript | Wordpress | Tutorials-Web Development | Reference | Books and More
原文地址:Easier Authentication with Guard in Symfony 3, 感谢原作者分享。