[Fix] DB connection errors with JWT refresh token#150
Merged
Conversation
…ttings - Introduced a decorator `retry_db_operation` to handle connection-related errors during database operations with configurable retry parameters. - Updated `Settings` class to include additional PostgreSQL connection settings: `pool_pre_ping`, `pool_recycle`, `connect_timeout`, and `command_timeout`. - Refactored user-related database queries in `accounts.py` to utilize the new retry mechanism for improved reliability.
- Enhanced AuthRepository to store and manage refresh tokens, allowing for access token renewal without re-authentication. - Updated server-side authentication endpoints to generate and validate refresh tokens, improving user session management. - Introduced new schemas for refresh token requests and responses, ensuring proper data handling. - Refactored JWT handling to support token pair creation, including both access and refresh tokens.
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.
This pull request introduces a robust refresh token mechanism for authentication, improves token management on both backend and frontend, and adds reliability enhancements for database operations. The changes ensure users can securely refresh access tokens without repeated logins, and the backend now issues both access and refresh tokens. Additionally, database queries are made more resilient to connection errors.
Authentication and Token Management
Tokenschema,/tokenand/token/refreshendpoints, token pair generation) [1] [2] [3] [4]./token/refresh), using minimal user info and without requiring database access [1] [2].AuthRepositoryto store, retrieve, and use refresh tokens for access token renewal and logout, persisting tokens inlocalStorage.Database Reliability
retry_db_operationdecorator to automatically retry database operations on connection errors, improving robustness against transient failures.user_exists,get_user_by_username,get_user_by_api_key) for increased reliability.Configuration Improvements
Settings, enabling better control of database connection behavior and resilience [1] [2].Other Minor Changes
pmid,doi) from document query logic for cleaner code.