From 6f7cae9e24b7e5508c10aa1ee88fa0730d64421d Mon Sep 17 00:00:00 2001 From: "admin.schubert" Date: Thu, 2 Jul 2026 14:20:08 +0000 Subject: [PATCH] feat(auth): add secure configuration and environment support --- backend/hermes/.env.example | 6 ++++ backend/hermes/.gitignore | 21 ++++++++++++++ backend/hermes/app/core/config.py | 9 +++--- backend/hermes/app/core/security.py | 9 ++++-- docker-compose.yml | 43 +++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 backend/hermes/.env.example create mode 100644 backend/hermes/.gitignore create mode 100644 docker-compose.yml diff --git a/backend/hermes/.env.example b/backend/hermes/.env.example new file mode 100644 index 0000000..6035eb9 --- /dev/null +++ b/backend/hermes/.env.example @@ -0,0 +1,6 @@ +DATABASE_URL=postgresql+psycopg://user:password@postgres:5432/olympus + +SECRET_KEY=CHANGE_ME + +APP_NAME=Hermes API +APP_VERSION=0.1.0 diff --git a/backend/hermes/.gitignore b/backend/hermes/.gitignore new file mode 100644 index 0000000..ff91dd5 --- /dev/null +++ b/backend/hermes/.gitignore @@ -0,0 +1,21 @@ +# Python +__pycache__/ +*.py[cod] +*.pyo + +# Virtual Environment +.venv/ +venv/ + +# Environment +.env + +# Alembic +alembic/versions/__pycache__/ + +# IDE +.vscode/ +.idea/ + +# macOS +.DS_Store diff --git a/backend/hermes/app/core/config.py b/backend/hermes/app/core/config.py index 2a3355c..95ebea4 100644 --- a/backend/hermes/app/core/config.py +++ b/backend/hermes/app/core/config.py @@ -2,15 +2,16 @@ from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): + database_url: str + secret_key: str + app_name: str = "Hermes API" app_version: str = "0.1.0" - database_url: str - model_config = SettingsConfigDict( env_file=".env", - case_sensitive=False + extra="ignore", ) -settings = Settings() \ No newline at end of file +settings = Settings() diff --git a/backend/hermes/app/core/security.py b/backend/hermes/app/core/security.py index 6fe5877..915ca85 100644 --- a/backend/hermes/app/core/security.py +++ b/backend/hermes/app/core/security.py @@ -3,9 +3,10 @@ from datetime import UTC, datetime, timedelta from jose import jwt from pwdlib import PasswordHash +from app.core.config import settings + password_hash = PasswordHash.recommended() -SECRET_KEY = "CHANGE_ME" ALGORITHM = "HS256" ACCESS_TOKEN_EXPIRE_MINUTES = 60 @@ -26,4 +27,8 @@ def create_access_token(subject: str) -> str: "exp": expire, } - return jwt.encode(payload, SECRET_KEY, algorithm=ALGORITHM) \ No newline at end of file + return jwt.encode( + payload, + settings.secret_key, + algorithm=ALGORITHM, + ) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..91093de --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,43 @@ +services: + hermes: + build: + context: ./backend/hermes + dockerfile: dockerfile + container_name: hermes-api + restart: unless-stopped + + environment: + DATABASE_URL: ${DATABASE_URL} + APP_NAME: Hermes API + APP_VERSION: 0.1.0 + SECRET_KEY: ${SECRET_KEY} + + ports: + - "8000:8000" + + networks: + - olympus-network + + athena: + build: + context: ./frontend/athena + dockerfile: Dockerfile + container_name: athena-web + restart: unless-stopped + + environment: + NODE_ENV: production + NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL} + + ports: + - "3001:3000" + + depends_on: + - hermes + + networks: + - olympus-network + +networks: + olympus-network: + external: true