18 feature request pass request object to custom auth backend #19
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.
This pull request refactors the authentication logic to ensure all authentication methods consistently receive both the
RequestandResponseobjects, improving extensibility and clarity in the API. It updates the method signatures for authentication classes and functions, and adjusts all usages and tests to match the new interface.Core authentication API changes
Updated all authentication method signatures (
BaseAuth.authenticate,JwtAuth.authenticate, andverify_current_user) to accept bothrequest: Requestandresponse: Responseas parameters, instead of justResponse. This change ensures future compatibility and allows authentication logic to access request context if needed. [1] [2] [3]Updated calls to
auth_backend.authenticatethroughoutverify_current_userand related classes to pass bothrequestandresponseobjects, ensuring consistent usage of the new interface. [1] [2]Test suite updates
test_auth_backend.py,test_jwt_auth.py) to use the new method signatures, passingrequest=Nonewhere appropriate, and updating mock calls and assertions. This maintains test coverage and correctness after the API change. [1] [2] [3] [4]Dependency and import updates
Requestfromfastapiin all relevant files to support the new parameter requirements. [1] [2] [3]Minor improvements
datetime.UTCimport for clarity and future compatibility.