symfony-docs
symfony-docs copied to clipboard
[Security] Use instanceof NullToken in voters
To test if the user is not logged.
@OskarStark changes applied, thank you :)
Sorry to ping you again @chalasr but could you please review if this security-related proposal is correct? Thanks.
(No worry @javiereguiluz, don't hesitate!)
I'm not totally sure about this change. Technically, the current code is correct as it covers the NullToken case as well as any eventual "unauthenticated" custom token (ref https://github.com/symfony/symfony/pull/42650).
With that in mind and given "use NullToken but only in voters" makes it way more complicated, I think it's better to keep the example it as-is.
Having @wouterj's point of view would be good though.
Indeed... Actually I'm not sure about my change anymore 😁
OK, let's close this then. Thank you all for the reviews 🙏