Be more lenient with route arguments in AuthencationMiddleware 'requires' decorator#942
Merged
erewok merged 2 commits intoKludex:masterfrom Aug 16, 2020
Conversation
69fe740 to
4e39caf
Compare
v0y
approved these changes
Jun 28, 2020
v0y
left a comment
There was a problem hiding this comment.
very nice MR with very nice tests, pls merge asap
kurzacz
approved these changes
Jun 29, 2020
erewok
approved these changes
Aug 16, 2020
Contributor
Author
|
@erewok Any chance there will be a release in the near future that incorporates this fix? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As mentioned in #794 (comment) the
@requiresdecorator is too strict as to where it expects arguments to be. It always expects there to be at least one non-keyword argument that is the request.With a custom decorator (that is similar to the dependency injection in FastAPI) this assumption breaks. Looking at the code it looks like the
@requiresdecorator already supports getting the request from the keyword arguments but still expects there to be a non-emptyargslist.So I added back the default value of
Nonein case there are noargspassed to the route call. It will still fail at runtime if no request parameter is given.I also added tests to the test suite that cover all three cases.