added redis authenticaiton
This commit is contained in:
@@ -16,10 +16,11 @@ app = FastAPI()
|
|||||||
# Secret API Key
|
# Secret API Key
|
||||||
SECRET_PHRASE = os.getenv("API_SECRET", "my_secret_key")
|
SECRET_PHRASE = os.getenv("API_SECRET", "my_secret_key")
|
||||||
|
|
||||||
# Redis for Rate Limiting
|
# Use the Redis password from the environment variable
|
||||||
REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379")
|
REDIS_URL = os.getenv("REDIS_URL", "redis://:my_redis_password@redis:6379")
|
||||||
redis_client = redis.from_url(REDIS_URL)
|
redis_client = redis.from_url(REDIS_URL)
|
||||||
|
|
||||||
|
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
async def startup():
|
async def startup():
|
||||||
"""Initialize FastAPI Limiter."""
|
"""Initialize FastAPI Limiter."""
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
environment:
|
environment:
|
||||||
- API_SECRET=my_secret_key
|
- API_SECRET=kokeserver
|
||||||
- REDIS_URL=redis://redis:6379
|
- REDIS_URL=redis://:my_redis_password@redis:6379
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
networks:
|
networks:
|
||||||
@@ -20,6 +20,7 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "6379:6379"
|
- "6379:6379"
|
||||||
|
command: redis-server --requirepass my_redis_password
|
||||||
networks:
|
networks:
|
||||||
- screenshot-network
|
- screenshot-network
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user