feat(auth): add secure configuration and environment support
This commit is contained in:
parent
56df3228a4
commit
6f7cae9e24
5 changed files with 82 additions and 6 deletions
6
backend/hermes/.env.example
Normal file
6
backend/hermes/.env.example
Normal file
|
|
@ -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
|
||||||
21
backend/hermes/.gitignore
vendored
Normal file
21
backend/hermes/.gitignore
vendored
Normal file
|
|
@ -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
|
||||||
|
|
@ -2,14 +2,15 @@ from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
class Settings(BaseSettings):
|
||||||
|
database_url: str
|
||||||
|
secret_key: str
|
||||||
|
|
||||||
app_name: str = "Hermes API"
|
app_name: str = "Hermes API"
|
||||||
app_version: str = "0.1.0"
|
app_version: str = "0.1.0"
|
||||||
|
|
||||||
database_url: str
|
|
||||||
|
|
||||||
model_config = SettingsConfigDict(
|
model_config = SettingsConfigDict(
|
||||||
env_file=".env",
|
env_file=".env",
|
||||||
case_sensitive=False
|
extra="ignore",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,10 @@ from datetime import UTC, datetime, timedelta
|
||||||
from jose import jwt
|
from jose import jwt
|
||||||
from pwdlib import PasswordHash
|
from pwdlib import PasswordHash
|
||||||
|
|
||||||
|
from app.core.config import settings
|
||||||
|
|
||||||
password_hash = PasswordHash.recommended()
|
password_hash = PasswordHash.recommended()
|
||||||
|
|
||||||
SECRET_KEY = "CHANGE_ME"
|
|
||||||
ALGORITHM = "HS256"
|
ALGORITHM = "HS256"
|
||||||
ACCESS_TOKEN_EXPIRE_MINUTES = 60
|
ACCESS_TOKEN_EXPIRE_MINUTES = 60
|
||||||
|
|
||||||
|
|
@ -26,4 +27,8 @@ def create_access_token(subject: str) -> str:
|
||||||
"exp": expire,
|
"exp": expire,
|
||||||
}
|
}
|
||||||
|
|
||||||
return jwt.encode(payload, SECRET_KEY, algorithm=ALGORITHM)
|
return jwt.encode(
|
||||||
|
payload,
|
||||||
|
settings.secret_key,
|
||||||
|
algorithm=ALGORITHM,
|
||||||
|
)
|
||||||
|
|
|
||||||
43
docker-compose.yml
Normal file
43
docker-compose.yml
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue