This commit is contained in:
Tykayn 2025-02-14 15:35:03 +01:00 committed by tykayn
parent d8c1b7c0f6
commit d01ecdabba
13 changed files with 198 additions and 25 deletions

View file

@ -1,33 +1,36 @@
# config/packages/security.yaml
security:
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
# Hashers pour les mots de passe
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
App\Entity\User:
algorithm: auto
# Fournisseurs d'utilisateurs
providers:
# used to reload user from session & other features (e.g. switch_user)
app_user_provider:
entity:
class: App\Entity\User
property: email
# Firewalls
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
provider: app_user_provider
form_login:
# "app_login" is the name of the route created previously
login_path: app_login
check_path: app_login
# access_token:
# token_handler: App\Security\AccessTokenHandler
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#the-firewall
# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
# Contrôle d'accès
access_control:
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/logged, roles: ROLE_USER }
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/logged, roles: ROLE_USER }
# - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } # Autoriser l'accès à la page de connexion
# - { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY } # Autoriser l'accès anonyme à toutes les autres pages
when@test:
security:

View file

@ -25,3 +25,7 @@ services:
Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler:
arguments:
- '%env(DATABASE_URL)%'
App\Filter\UserProductsFilter:
arguments: [ '@security.helper' ]
tags: [ 'api_platform.filter' ]