farvest / security-bundle
Security bundle test to provide login page to accesss administration pages.
Requires
- php: ^8.1
- doctrine/orm: ^2.9
- flagstone/action-logging-bundle: ^1.0
- flagstone/base-entity-bundle: ^1.0
- flagstone/encryption-doctrine-bridge-bundle: ^1.0
- flagstone/flash-message-bundle: ^1.0
- flagstone/mailing-bundle: ^0.0.15
- flagstone/translator-bundle: ^1.0
- flagstone/uuid-generator-bundle: ^1.0
- symfony/asset: ^6.0
- symfony/console: ^6.0
- symfony/form: ^6.0
- symfony/framework-bundle: ^6.0
- symfony/http-foundation: ^6.0
- symfony/security-bundle: ^6.0
- symfony/templating: ^6.0
- symfony/translation: ^6.0
- symfony/validator: ^6.0
Requires (Dev)
- symfony/css-selector: ^6.0
- symfony/webpack-encore-bundle: ^1.6
- symfony/yaml: ^6.0
- dev-master
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 1.0.17.1
- 1.0.17
- 1.0.16.4
- 1.0.16.3
- 1.0.16.2
- 1.0.16.1
- 1.0.16
- 1.0.15.6
- 1.0.15.5
- 1.0.15.4
- 1.0.15.3
- 1.0.15.2
- 1.0.15.1
- 1.0.15
- 1.0.14.14
- 1.0.14.13
- 1.0.14.12
- 1.0.14.11
- 1.0.14.10
- 1.0.14.9
- 1.0.14.8
- 1.0.14.7
- 1.0.14.6
- 1.0.14.5
- 1.0.14.4
- 1.0.14.3
- 1.0.14.2
- 1.0.14.1
- 1.0.14
- 1.0.13.4
- 1.0.13.3
- 1.0.13.2
- 1.0.13.1
- 1.0.13
- 1.0.12.11
- 1.0.12.10
- 1.0.12.9
- 1.0.12.8
- 1.0.12.7
- 1.0.12.6
- 1.0.12.5
- 1.0.12.4
- 1.0.12.3
- 1.0.12.2
- 1.0.12.1
- 1.0.12
- 1.0.11.8
- 1.0.11.7
- 1.0.11.6
- 1.0.11.5
- 1.0.11.4
- 1.0.11.3
- 1.0.11.2
- 1.0.11.1
- 1.0.11
- 1.0.10.2
- 1.0.10.1
- 1.0.10
- 1.0.9.6
- 1.0.9.5
- 1.0.9.4
- 1.0.9.3
- 1.0.9.2
- 1.0.9.1
- 1.0.9
- 1.0.8.10
- 1.0.8.9
- 1.0.8.8
- 1.0.8.7
- 1.0.8.6
- 1.0.8.5
- 1.0.8.4
- 1.0.8.3
- 1.0.8.2
- 1.0.8.1
- 1.0.8
- 1.0.7.7
- 1.0.7.6
- 1.0.7.5
- 1.0.7.4
- 1.0.7.3
- 1.0.7.2
- 1.0.7.1
- 1.0.7
- 1.0.6.12
- 1.0.6.11
- 1.0.6.10
- 1.0.6.9
- 1.0.6.8
- 1.0.6.7
- 1.0.6.6
- 1.0.6.5
- 1.0.6.4
- 1.0.6.3
- 1.0.6.2
- 1.0.6.1
- 1.0.6
- 1.0.5.15
- 1.0.5.14
- 1.0.5.13
- 1.0.5.12
- 1.0.5.11
- 1.0.5.10
- 1.0.5.9
- 1.0.5.8
- 1.0.5.7
- 1.0.5.6
- 1.0.5.5
- 1.0.5.4
- 1.0.5.3
- 1.0.5.2
- 1.0.5.1
- 1.0.5
- 1.0.4.9
- 1.0.4.8
- 1.0.4.7
- 1.0.4.6
- 1.0.4.4
- 1.0.4.3
- 1.0.4.1
- 1.0.4
- 1.0.3.1
- 1.0.3
- 1.0.2.1
- 1.0.2
- 1.0.1
- 0.1.12
- dev-dev
This package is auto-updated.
Last update: 2024-10-29 05:59:54 UTC
README
Security Bundle by Flagstone. Create login and logout root for admin access
Installation
Use composer manager to install it
composer install flagstone/security-bundle
To add the user entity to your database, you just have to make a standard migration.
php bin/console make:migration
php bin/console doctrine:migrations:migrate
Import Routes
In the routing file of your application, add the following
flagstone_security:
resource: '@FlagstoneSecurityBundle/Resources/config/routes_security.yaml'
prefix:
en: ''
fr: '/fr'
de: '/de'
flagstone_security_user:
resource: '@FlagstoneSecurityBundle/Resources/config/routes_user.yaml'
prefix:
en: '/admin'
fr: '/fr/admin'
de: '/de/admin'
The bundle define 2 distinct routes. The first one is to access to the user management, the second give a routing for /login
and /logout
routes. So you can define distinct prefix for these 2 routes.
Configuration
This bundle uses the Symfony security bundle. So you just have to configure the security with the security.yaml file, like this example:
security:
enable_authenticator_manager: true
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
providers:
user:
entity:
class: Flagstone\SecurityBundle\Entity\User
property: username
firewalls:
dev:
pattern: (_(profiler|wdt)|css|images|js)/
security: false
admin:
lazy: true
logout:
path: logout
target: login
provider: user
custom_authenticator:
- Flagstone\SecurityBundle\Security\UserFormAuthenticator
main:
lazy: true
security: false
role_hierarchy:
ROLE_COMMENT: ROLE_GUEST
ROLE_BLOG: ROLE_COMMENT
ROLE_ADMIN: ROLE_BLOG
ROLE_DEV: [ROLE_GUEST, ROLE_COMMENT, ROLE_BLOG, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
access_control:
- { path: ^/admin/login, roles: PUBLIC_ACCESS}
- { path: ^/admin/user, roles: ROLE_DEV}
- { path: ^/admin, roles: ROLE_ADMIN}
The bundle uses 3 parameters to define the route for login_form and success login and the list of roles you want.
availableRoles:
- 'ROLE_DEV'
- 'ROLE_ADMIN'
- 'ROLE_USER'
- 'ROLE_GUEST'
fs_adminIndex: 'fs_admin_index'
fs_loginRoute: 'fs_admin_login'
Default values are set, but you can overwrite these parameters in your services.yaml.
Usage
Create an user
You can use the embed user creation command console. You can create the first admin user :
php bin/console flagstone-security:create-admin
Answer all questions and then, a new user is created, with admin privileges.
TODO
- Add a logging system to know who make what.
- Add configuration to know what can be do by a role user (who can delete, who can edit...). Define actions by role.