Skip to content

Conversation

@Iamsdt
Copy link
Collaborator

@Iamsdt Iamsdt commented Dec 1, 2025

This pull request refactors the authentication logic to ensure all authentication methods consistently receive both the Request and Response objects, 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, and verify_current_user) to accept both request: Request and response: Response as parameters, instead of just Response. This change ensures future compatibility and allows authentication logic to access request context if needed. [1] [2] [3]

  • Updated calls to auth_backend.authenticate throughout verify_current_user and related classes to pass both request and response objects, ensuring consistent usage of the new interface. [1] [2]

Test suite updates

  • Refactored all unit tests for authentication (test_auth_backend.py, test_jwt_auth.py) to use the new method signatures, passing request=None where 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

  • Updated import statements to include Request from fastapi in all relevant files to support the new parameter requirements. [1] [2] [3]

Minor improvements

  • Updated JWT token expiration test to use the new datetime.UTC import for clarity and future compatibility.

@Iamsdt Iamsdt linked an issue Dec 1, 2025 that may be closed by this pull request
@Iamsdt Iamsdt merged commit 1af0612 into main Dec 1, 2025
1 check passed
@Iamsdt Iamsdt deleted the 18-feature-request-pass-request-object-to-custom-auth-backend branch December 1, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Pass Request Object to Custom Auth Backend

2 participants