feat: add Redis persistence support for OAuth token and client storage - #68
Open
yashpawar6849 wants to merge 2 commits into
Open
feat: add Redis persistence support for OAuth token and client storage#68yashpawar6849 wants to merge 2 commits into
yashpawar6849 wants to merge 2 commits into
Conversation
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 14 days if no further activity occurs. If this PR is still in progress, please comment or push new commits. |
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.
Description
This PR adds Redis as an optional storage backend for OAuth persistence, alongside the existing PostgreSQL support.
Currently, the server only supports PostgreSQL for storing OAuth clients, authorization codes, access tokens, and refresh tokens.
This PR:
Introduces a BaseStorageService abstract class to decouple the OAuth layer from any specific database engine.
Implements RedisStorageService using redis.asyncio, leveraging native Redis TTLs (SETEX) for automatic token expiration no manual cleanup needed.
Adds a STORAGE_TYPE config setting (postgres or redis) with full backward compatibility existing deployments default to postgres and require no changes.
Adds Redis environment variables (REDIS_HOST, REDIS_PORT, REDIS_PASSWORD, REDIS_DB) and a redis:7-alpine container in compose.yaml for local development.
Related Issues
#67
Type of Change
Checklist
make test)make pre-commit)make coverage)CHANGELOG.md(if applicable)make test)make pre-commit)make coverage)CHANGELOG.md(if applicable)Testing
All changes were tested using the project's existing test suite extended with new unit tests for RedisStorageService.
Added 44 new unit tests in tests/test_redis_service.py using unittest.mock to mock redis.asyncio calls — no live Redis instance required.
Screenshots / Logs