added redis authenticaiton
This commit is contained in:
@@ -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."""
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user