-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
🐛 Fix OAuth2PasswordRequestForm
and OAuth2PasswordRequestFormStrict
fixed grant_type
"password" RegEx
#9783
🐛 Fix OAuth2PasswordRequestForm
and OAuth2PasswordRequestFormStrict
fixed grant_type
"password" RegEx
#9783
Conversation
I wonder if we should let the user decide the pattern, rather than forcing a stricter requirement by default. |
My understanding is that this class is specifically for the OAuth2 password flow If the user wants a different flow they can implement it themselves, or a more general class should be provided. |
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.
Reviewed this PR. Everything is good!
- Tests fail before changes (returns response=
200
instead of422
when passinggrant_type
'prefix password' or 'password suffix'). - Tests are Ok after applying changes.
- Documentation is Ok (there is no need to change anything)
I've resolved the merge conflicts. |
Hi @skarfie123, thanks for your interest in contributing to FastAPI. We appreciate your effort and the time you have taken to submit this PR. We have a high volume of PRs and we're working hard to review and classify them. We appreciate your patience as we managed the queue, we'll review your PR soon. Thanks! 🙇♀️ |
No worries @alejsdev ! I've resolved the merge conflicts again. |
I already checked it and it's ok, from my point of view it's ready to be merged, I'll leave the final decision to @tiangolo 🚀 |
I merged in |
OAuth2PasswordRequestForm
and OAuth2PasswordRequestFormStrict
fixed grant_type
"password" RegEx
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.
Nice, thank you! 🚀 🐛
And thanks for the reviews and help everyone! ☕
When using the OAuth2 password request form, the regex for the
grant_type
is not strict enough. It currently allows any string that contains the word "password" in it.The docstring says:
This PR changes the regex to ensure the exact string.
I also added extra test cases to cover this.
Minimal example:
Using the Swagger UI docs to test, with
grant_type=passwordblah
it returns 200 before but 422 after the change, as expected.