Chapter 4 of the Symfony for PHP developers track
The keys to the tavern
6 exercises · 1,290 XP · about 3 h 30 min
Firewallform_loginaccess_controlUserInterfaceEntity providerHashingrole_hierarchyIsGrantedis_granted()VoterIsGranted with a subjectCurrentUserUserPasswordRepeatedTypeDebuggingRole hierarchy
The chapter's exercises
-
Who goes there?
Exercise 1 · 200 XP · 5 objectives checked by tests
Scandal at the tavern: a customer found the /kitchen/new-dish page and added a “Pippin's Stew, free of charge” to the menu. The kitchen must be closed to the public: only Bruna gets in.
Firewallform_loginaccess_control
-
The staff register
Exercise 2 · 200 XP · 5 objectives checked by tests
Bruna no longer works alone: Gorm wants to get into the kitchen too, and he has hired Pippin (to wait tables). Declare every staff member in security.yaml, and redeploy at every hire? Unthinkable. The accounts are going to live in the database.
UserInterfaceEntity providerHashing
-
To each their role
Exercise 3 · 200 XP · 5 objectives checked by tests
Gorm, the boss (ROLE_PATRON), can do everything;
role_hierarchyIsGrantedis_granted()
-
To each their own dishes
Exercise 4 · 220 XP · 5 objectives checked by tests
Lugh, a new cook, “improved” Bruna's pie by adding anchovies. Bruna is furious. New rule in the kitchen: to each their own dishes. A cook only edits the dishes they invented, and the boss can edit everything.
VoterIsGranted with a subjectCurrentUser
-
Changing the lock
Exercise 5 · 220 XP · 5 objectives checked by tests
Pippin pinned everyone's passwords on the order board, “so he wouldn't forget them”. It's urgent to change the locks: every staff member must be able to change their password.
UserPasswordRepeatedTypeHashing
-
🐉 Boss: the stolen keys
Exercise 6 · 250 XP · 4 objectives checked by tests
After the business with the board, Pippin felt guilty. He decided to “tighten security” all by himself, during the night, “tidying up a bit” along the way.