I haven't found a tutorial in the official Symfony documentation, but I'd like to know if it's possible, via the security.yaml file, to configure two separate connections: one for the administrator interface and client connection page, and a second for the player connection page (quiz games, fictitious players created by the administrator). So for this, I have two different entities which are the "Player" and the "Users" (admin).
I've also created two separate connections (twig and controller) with symfony console make:auth .
However, I'm having trouble configuring all this, and errors occur when I log out. Is it possible to have two firewall entries? I think that's where my error is coming from. Here's what I've done:
security:
providers:
app_user_provider:
entity:
class: App\Entity\User
property: email
app_player_provider:
entity:
class: App\Entity\Player
property: email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login_admin:
pattern: ^/login-admin
provider: app_user_provider
custom_authenticator: App\Security\AppAuthenticator
logout:
path: app_logout_user
login_player:
pattern: ^/login
provider: app_player_provider
custom_authenticator: App\Security\AppAuthenticatorPlayerAuthenticator
logout:
path: app_logout
user_checker : App\Security\PlayerChecker
role_hierarchy:
ROLE_ADMIN: ROLE_ADMIN
ROLE_CLIENT: ROLE_CLIENT
ROLE_USER: ROLE_USER
access_control:
- { path: ^/, role: PUBLIC_ACCESS }
- { path: ^/login, role: PUBLIC_ACCESS }
- { path: ^/login-admin, role: PUBLIC_ACCESS }
- { path: ^/admin, roles: [ROLE_ADMIN,ROLE_CLIENT] }
- { path: ^/stats, roles: ROLE_ADMIN }
Thank you in advance for your help ^^
Otherwise, here is the symfony error:
This method can be blank - it will be intercepted by the logout key on your firewall.
I had tested the providers method, but it doesn't work as I'd like. The player can't log in on the user page, whereas the admin can log in on both login pages. This isn't ideal for security, because players could have simple passwords (like the name of a country, for example, for the game) and players could be blocked so that logging in is only possible for the duration of the game, which is about 1 hour.
providers:
app_user_provider:
entity:
class: App\Entity\User
property: email
app_player_provider:
entity:
class: App\Entity\Player
property: email
app_provider:
chain:
providers: [app_user_provider, app_player_provider]