Twig ships with some default global variables that you can use. Where does this variables come from?
app/console twig:debug
You will see a Globals section. Take the ‘app’ variable for example, you can find all the variables available in that file. That is why {{ app.user }} works. To see all the variables in app.user, {{ dump(app.user) }}