A Symfony bundle focused on identification and the management of users, roles and groups.
- 👤 User Management: Complete user entity with email authentication
- 🆔 User Access: Login with form or magic login link
- ⏳ Account Activation: Optional email verification for new users
- 🔄 Password Management: Secure password hashing and reset functionality
- 📧 Email Integration: Built-in email templates for login links and password resets
- 🕒 Last Login Tracking: Automatically updates last login timestamp
- 🔐 Role-Based Access Control: Flexible role system with many-to-many relationships
- 👥 Group Support: Organize users into groups with inherited roles
- 🔒 Security Integration: Full integration with Symfony Security component
- 📊 Doctrine ORM: Ready-to-use entities with Doctrine annotations
- ⚙️ Configurable: Easy configuration through YAML files
Install the bundle via Composer:
composer require fastfony/identity-bundleThis will automatically install the required dependencies including:
stof/doctrine-extensions-bundlefor automatic timestamp managementsymfony/mailer symfony/notifier symfony/twig-bundle twig/extra-bundle twig/cssinliner-extra twig/inky-extrafor email functionalitiessymfony/rate-limiterfor login throttlingsymfony/translationfor translationssymfony/uidfor unique identifiers (in the reset functionality)symfony/formfor register, login and password request form view and handling
If you're using Symfony Flex, the bundle will be automatically enabled. Otherwise, add it to config/bundles.php:
return [
// ...
Fastfony\IdentityBundle\FastfonyIdentityBundle::class => ['all' => true],
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
];If you're using Symfony Flex, the configuration file will be created automatically. Otherwise, manually do it:
Create or edit Doctrine Extensions config file in config/packages/stof_doctrine_extensions.yaml:
stof_doctrine_extensions:
default_locale: en_US
orm:
default:
timestampable: trueEdit security settings in config/packages/security.yaml for add the firewall, an user provider and a new access control rule:
security:
# ...
providers:
# ...
fastfony_identity_user_provider:
entity:
class: Fastfony\IdentityBundle\Entity\Identity\User
property: email
# ...
firewalls:
dev:
# ...
fastfony_identity:
lazy: true
provider: fastfony_identity_user_provider
user_checker: Fastfony\IdentityBundle\Security\UserChecker
form_login:
login_path: form_login
check_path: form_login
enable_csrf: true
csrf_token_id: login
form_only: true
login_link:
check_route: login_check
signature_properties: [ id, email ]
max_uses: 3
entry_point: Fastfony\IdentityBundle\Security\CustomEntryPoint
remember_me:
always_remember_me: true
signature_properties: [ 'id', 'email', 'password' ]
switch_user: true
login_throttling:
max_attempts: 3
logout:
path: /logout
clear_site_data:
- cookies
- storage
# ... (here your other firewalls)
access_control:
# ...
- { path: ^/secure-area/, roles: ROLE_USER } # Adjust as neededImport the bundle routing in config/routes/fastfony_identity.yaml:
fastfony_identity:
resource: "@FastfonyIdentityBundle/config/routes/all.yaml"Configure the default sender email address in config/packages/mailer.yaml:
framework:
mailer:
dsn: '%env(MAILER_DSN)%'
envelope:
sender: 'noreply@your-website.com'(don't forget to set the MAILER_DSN environment variable in your .env file, more info here)
Generate and run migrations to create the database tables:
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrateAlternatively, you can create the schema directly:
php bin/console doctrine:schema:update --forceIt's done! 🥳 You can now start using the bundle.
More detailed usage instructions and customizations can be found in the Documentation.
This bundle is released under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
For issues, questions, or contributions, please visit the GitHub repository.