Symfony

Security & Authentication

Firewalls, providers, encoders, voters, authenticators, JWT, OAuth2, access control

26 interview questionsยท
Mid-Level
1

What is the main role of a firewall in Symfony's Security component?

Answer

A firewall in Symfony defines a security zone for a part of the application. It determines how users are authenticated (form, token, API key) and which URLs are protected. Each firewall can have its own authentication configuration and user provider.

2

What is a User Provider in Symfony Security?

Answer

A User Provider is responsible for loading user information from a data source (database, LDAP, external API). It implements the UserProviderInterface and provides methods to load a user by identifier or refresh user data from the session.

3

Which interface must a User class implement to be used with Symfony Security?

Answer

The User class must implement UserInterface which defines essential methods: getUserIdentifier() for the unique identifier, getRoles() for roles, and eraseCredentials() to erase sensitive data. PasswordAuthenticatedUserInterface is also required for password authentication.

4

How to define role-based access control in security.yaml?

5

What is the difference between authentication and authorization in Symfony Security?

+23 interview questions

Master Symfony for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free