Skip to content

feat: add Redis persistence support for OAuth token and client storage - #68

Open
yashpawar6849 wants to merge 2 commits into
redhat-data-and-ai:mainfrom
yashpawar6849:yashpawar6849
Open

feat: add Redis persistence support for OAuth token and client storage#68
yashpawar6849 wants to merge 2 commits into
redhat-data-and-ai:mainfrom
yashpawar6849:yashpawar6849

Conversation

@yashpawar6849

@yashpawar6849 yashpawar6849 commented Jun 15, 2026

Copy link
Copy Markdown

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

  • Bug fix (non-breaking change that fixes an issue)
  • [ ✅ ] New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or infrastructure change
  • Dependency update

Checklist

  • [✅ ] My code follows the project's coding standards (Ruff, MyPy, pydocstyle)
  • [✅ ] I have added tests that prove my fix is effective or my feature works
  • [ ✅ ] All new and existing tests pass (make test)
  • [✅ ] Pre-commit hooks pass (make pre-commit)
  • [✅ ] Code coverage remains >= 80% (make coverage)
  • [ ✅ ] I have updated documentation where necessary
  • [ ✅ ] I have updated CHANGELOG.md (if applicable)
  • [ ✅ ] My PR title follows Conventional Commits forma] My code follows the project's coding standards (Ruff, MyPy, pydocstyle)
  • [✅ ] I have added tests that prove my fix is effective or my feature works
  • [ ✅] All new and existing tests pass (make test)
  • [ ✅ ] Pre-commit hooks pass (make pre-commit)
  • [✅ ] Code coverage remains >= 80% (make coverage)
  • [ ✅ ] I have updated documentation where necessary
  • [ ✅ ] I have updated CHANGELOG.md (if applicable)
  • [✅] My PR title follows Conventional Commits format

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.

  • Tests cover connection lifecycle, health checks, status reporting, and all CRUD operations (clients, authorization codes, access tokens, refresh tokens) including happy-path, not-found, no-connection, and exception scenarios.
  • Verified that existing PostgreSQL storage tests (test_storage_service.py, test_storage_init.py) continue to pass without modification.
  • Verified the new BaseStorageService abstraction works correctly for both backends.

Screenshots / Logs

@github-actions

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant