-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[SecurityBundle] Empty line starting with dash under "access_control" causes all rules to be skipped #40330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SecurityBundle] Empty line starting with dash under "access_control" causes all rules to be skipped #40330
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I'm merely nit-picking here. 🙂
src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php
Outdated
Show resolved
Hide resolved
Thank you for creating this PR including tests and a reproducer, @monteiro! That's perfect! After looking at the changes, I'm wondering whether we qualify this as a BC break. More precisely, people may have been using the "empty attributes" feature to exclude some routes from the access control (e.g. a login form). However, this was never documented behavior. Let's wait a bit for more comments from the core team whether or not this is a BC break. If we qualify it as such, I think it makes all sense to deprecate this in 5.x instead (and introducing this exception in 6.0). |
I thought about that as well and could live with going through the deprecation process for that.
My current understanding of the behavior (please correct me if I'm wrong) is that the empty line simply matches every request without applying any access restrictions. The result is effectively that any subsequent line would become unreachable. That behavior is dangerously surprising imho. Can we come up with a scenario where this change breaks an application that is not dangerously misconfigured? |
access_control:
- { path: ^/login }
- { path: ^/, roles: ROLE_USER } I haven't verified it, but as far as I understand the code, this yaml file is equal to doing The diff is checking |
@wouterj With your example, the exception in this PR should not be triggered. The case that is caught here is this one: access_control:
-
- { path: ^/, roles: ROLE_USER } |
@derrabus as indicated with my last sentence, this case is caught by this PR, as the check is done over |
Okay, that's indeed an issue then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to make sure that @wouterj's example still works.
src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
Outdated
Show resolved
Hide resolved
ebee522
to
e99bc3a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I was a bit too fast with my approval. I'm not 100% sure if my suggestions make sense.
src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
Outdated
Show resolved
Hide resolved
Let me know if there is anything I can do to help here. |
… causes all rules to be skipped
9c8f39c
to
ee26ce5
Compare
Thank you @monteiro. |
Thanks to you @derrabus |
When the IDE by mistake puts an empty line in
access_control
in security.yaml there is no warning that we have an empty row, making the rest of routes defined, to be ignored and possible to be accessed by anyone that can authenticate no matter the role.How to reproduce the issue
security.yaml
, "by mistake" it is possible to access the protectedROLE_ADMIN
route.