Download the PHP package mlukman/security-helper-bundle without Composer
On this page you can find all versions of the php package mlukman/security-helper-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mlukman/security-helper-bundle
More information about mlukman/security-helper-bundle
Files in mlukman/security-helper-bundle
Package security-helper-bundle
Short Description A set of classes to simplify Symfony security
License MIT
Informations about the package security-helper-bundle
Security Helper Bundle
About
Security Helper Bundle is a Symfony 7.x bundle that simplifies the implementation of AAA (authentication, authorization and audit) of a web application. It is a layer on top of the core Symfony Security Bundle.
Installation
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Applications that use Symfony Flex
Open a command console, enter your project directory and execute:
Applications that don't use Symfony Flex
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project:
Activation
While Composer helps a lot in installing this bundle, there are some further steps that are required to activate this bundle in your web application.
Create Doctrine entity that subclasses of UserEntity
Most of the columns configuration for authentication purposes are already implemented by the UserEntity
class except the #[ORM\Id]
field, which is intentionally left for the subclass to implement. Feel free to add relations as needed by your database design.
Example:
Implement AuthenticationRepositoryInterface
The implementation class needs to implement the following methods:
getDefaultRedirectRoute() : string
This method should return the route to redirect to if the information about the previous route is not available. The returned route will also be used to redirect user after logout.
newUserEntity(string $method, string $credential, string $username = null): UserEntity
Create new User entity object. This method should not save the object to database yet.
queryUserEntity(string $method, string $criteriaField, string $criteriaValue): ?UserEntity
Query a User entity based on method, criteriaField and criteriaValue. This method may return null if no such entity can be found.
queryUserEntityFromSecurityUser(UserInterface $securityUser): ?UserEntity
Query a User entity based on the pass UserInterface object. This method may return null if no such entity can be found.
saveUserEntity(UserEntity $user): void
Save the passed new/modified User entity object.
sendResetPasswordEmail(UserEntity $user): void
Send a reset password email to the user.
Implement LoginControllerInterface
The implementation class needs to implement the following method:
login(Request $request, ClientRegistry $clientRegistry): Response
Show login page that should contain one or more of the followings, depending on the authentication methods that you want to implement:
- Username & password input fields
- The buttons to login using OAuth2 providers
Register both implementations of AuthenticationRepositoryInterface and LoginControllerInterface
Add the following to your services.yaml
:
Register the bundle routing
Add a YAML file named security_helper.yaml
with the following content into your config/routes
folder (modify the prefix
parameter to your preference):
Register with the main Symfony Security Bundle
Merge the following settings into your config/packages/security.yaml
:
All versions of security-helper-bundle with dependencies
doctrine/orm Version ^2.8|^3.0
google/recaptcha Version ^1.3
knpuniversity/oauth2-client-bundle Version ^2.18
league/oauth2-facebook Version ^2.2
league/oauth2-github Version ^3.1
league/oauth2-google Version ^4.0
stevenmaguire/oauth2-keycloak Version ^5.1
symfony/console Version ^6.1|^7.0
symfony/framework-bundle Version ^6.1|^7.0
symfony/runtime Version ^6.1|^7.0
symfony/security-bundle Version ^6.1|^7.0
symfony/twig-bundle Version ^6.1|^7.0