From 2a47e00255d3b93cc02bbcafaf9bb96e24d033aa Mon Sep 17 00:00:00 2001 From: Johan Koke Date: Thu, 6 Feb 2025 15:32:04 +0000 Subject: [PATCH] added redis authenticaiton --- app/main.py | 5 +++-- docker-compose.yaml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/main.py b/app/main.py index 0f56c18..ffdb7b8 100644 --- a/app/main.py +++ b/app/main.py @@ -16,10 +16,11 @@ app = FastAPI() # Secret API Key SECRET_PHRASE = os.getenv("API_SECRET", "my_secret_key") -# Redis for Rate Limiting -REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379") +# Use the Redis password from the environment variable +REDIS_URL = os.getenv("REDIS_URL", "redis://:my_redis_password@redis:6379") redis_client = redis.from_url(REDIS_URL) + @app.on_event("startup") async def startup(): """Initialize FastAPI Limiter.""" diff --git a/docker-compose.yaml b/docker-compose.yaml index 9379f87..0249979 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -7,8 +7,8 @@ services: ports: - "80:80" environment: - - API_SECRET=my_secret_key - - REDIS_URL=redis://redis:6379 + - API_SECRET=kokeserver + - REDIS_URL=redis://:my_redis_password@redis:6379 depends_on: - redis networks: @@ -20,6 +20,7 @@ services: restart: always ports: - "6379:6379" + command: redis-server --requirepass my_redis_password networks: - screenshot-network