feat: signin rate limit

This commit is contained in:
Timothy Jaeryang Baek
2025-12-02 03:52:38 -05:00
parent 734c04ebf0
commit 7b16637043
3 changed files with 176 additions and 1 deletions

View File

@@ -5,7 +5,13 @@ import logging
import redis
from open_webui.env import REDIS_SENTINEL_MAX_RETRY_COUNT
from open_webui.env import (
REDIS_CLUSTER,
REDIS_SENTINEL_HOSTS,
REDIS_SENTINEL_MAX_RETRY_COUNT,
REDIS_SENTINEL_PORT,
REDIS_URL,
)
log = logging.getLogger(__name__)
@@ -108,6 +114,21 @@ def parse_redis_service_url(redis_url):
}
def get_redis_client(async_mode=False):
try:
return get_redis_connection(
redis_url=REDIS_URL,
redis_sentinels=get_sentinels_from_env(
REDIS_SENTINEL_HOSTS, REDIS_SENTINEL_PORT
),
redis_cluster=REDIS_CLUSTER,
async_mode=async_mode,
)
except Exception as e:
log.debug(f"Failed to get Redis client: {e}")
return None
def get_redis_connection(
redis_url,
redis_sentinels,