80 lines
3.3 KiB
YAML
80 lines
3.3 KiB
YAML
security:
|
|
# Hiérarchie des rôles - les rôles enfants héritent des rôles parents
|
|
role_hierarchy:
|
|
ROLE_ADMIN: [ROLE_USER]
|
|
ROLE_MODERATOR: [ROLE_USER]
|
|
|
|
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
|
|
password_hashers:
|
|
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
|
|
|
|
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
|
|
providers:
|
|
# used to reload user from session & other features (e.g. switch_user)
|
|
app_user_provider:
|
|
entity:
|
|
class: App\Entity\User
|
|
property: pseudo
|
|
api_user_provider:
|
|
entity:
|
|
class: App\Entity\User
|
|
property: pseudo
|
|
|
|
firewalls:
|
|
dev:
|
|
# Ensure dev tools and static assets are always allowed
|
|
pattern: ^/(_profiler|_wdt|assets|build)/
|
|
security: false
|
|
api:
|
|
pattern: ^/api
|
|
provider: app_user_provider
|
|
context: app_security
|
|
stateless: false
|
|
lazy: false
|
|
# Charger la session du context partagé automatiquement
|
|
# Cela permet à Symfony d'authentifier les utilisateurs connectés
|
|
# http_basic agit ici comme un fallback pour accepter les sessions
|
|
http_basic: ~
|
|
# Authenticateur pour gérer les tokens API (Bearer)
|
|
# Si pas de Bearer token, la session du context est utilisée
|
|
custom_authenticators:
|
|
- App\Security\ApiBearerTokenAuthenticator
|
|
main:
|
|
provider: app_user_provider
|
|
context: app_security # Utiliser le même contexte
|
|
form_login:
|
|
login_path: app_login # route GET (affichage formulaire)
|
|
check_path: app_login # route POST (traitement)
|
|
username_parameter: _username
|
|
password_parameter: _password
|
|
default_target_path: app_accueil
|
|
target_path_parameter: _target_path
|
|
failure_path: /
|
|
use_referer: true
|
|
enable_csrf: true
|
|
failure_handler: App\Security\LoginFailureHandler
|
|
success_handler: App\Security\LoginSuccessHandler
|
|
logout:
|
|
path: app_logout
|
|
|
|
# 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
|
|
|
|
# Note: Only the *first* matching rule is applied
|
|
access_control:
|
|
- { path: ^/administration, roles: ROLE_ADMIN }
|
|
- { path: ^/profile, roles: ROLE_USER }
|
|
|
|
when@test:
|
|
security:
|
|
password_hashers:
|
|
# Password hashers are resource-intensive by design to ensure security.
|
|
# In tests, it's safe to reduce their cost to improve performance.
|
|
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
|
|
algorithm: auto
|
|
cost: 4 # Lowest possible value for bcrypt
|
|
time_cost: 3 # Lowest possible value for argon
|
|
memory_cost: 10 # Lowest possible value for argon
|