-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Security] Prevent FormLoginAuthenticator from responding to requests that should be handled by JsonLoginAuthenticator
#41993
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
Conversation
|
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
wouterj
left a comment
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.
Hi! Thanks for starting the PR!
I think we should change the implementation a bit. Relying on "not JSON" means this authenticator is suddenly aware of other authenticators in the system and, more importantly, it will fail as soon as someone adds an XmlLoginAuthenticator. I also think this is a BC break: Some people use form_login in API requests (i.e. not form submissions), see for instance lexik/LexikJWTAuthenticationBundle#123 and api-platform/core#563
What do you think about changing this PR to add a new option form_only, defaulting to false, in FormLoginFactory and then doing $this->options['form_only'] && 'application/x-www-form-urlencoded' === $request->getContentType()?
Less important: please remove the CHANGELOG.md file you've added. The one in the root is automatically generated by the release tool (based on the PR title). If you don't add any class or option, you don't need to edit any CHANGELOG manually. If you implement my suggestion above, you should add a "Add form_login.form_only option" to the changelog in the SecurityBundle directory. Thanks!
I think your suggestions make much more sense. 👍 Changes implemented. |
chalasr
left a comment
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.
Please add a test for this.
Ugh..I'm not very strong at writing tests but I'll give it a go this evening once I'm off for the day.
|
|
If you have an account in the Symfony Slack, feel free to hop in |
FormLoginAuthenticator from responding to requests that should be handled by JsonLoginAuthenticator
|
friendly ping @abunch :) Do you want us to add a test for you? |
|
@chalasr Do you want to take over this one? |
…d be handled by JsonLoginAuthenticator
|
@fabpot done |
|
Thank you @abunch. |
Prevent FormLoginAuthenticator from responding to requests that should be handled by JsonLoginAuthenticator