Improve base config
This commit is contained in:
@@ -1,47 +1,56 @@
|
||||
# ================================================================
|
||||
# AUTH SERVICE CONFIGURATION
|
||||
# services/auth/app/core/config.py
|
||||
# ================================================================
|
||||
|
||||
"""
|
||||
Authentication service configuration
|
||||
User management and JWT token handling
|
||||
"""
|
||||
|
||||
from shared.config.base import BaseServiceSettings
|
||||
import os
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Application settings"""
|
||||
class AuthSettings(BaseServiceSettings):
|
||||
"""Auth service specific settings"""
|
||||
|
||||
# Basic settings
|
||||
# Service Identity
|
||||
APP_NAME: str = "Authentication Service"
|
||||
VERSION: str = "1.0.0"
|
||||
DEBUG: bool = os.getenv("DEBUG", "False").lower() == "true"
|
||||
LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
|
||||
SERVICE_NAME: str = "auth-service"
|
||||
DESCRIPTION: str = "User authentication and authorization service"
|
||||
|
||||
# Database settings
|
||||
DATABASE_URL: str = os.getenv("DATABASE_URL", "postgresql+asyncpg://auth_user:auth_pass123@auth-db:5432/auth_db")
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("AUTH_DATABASE_URL",
|
||||
"postgresql+asyncpg://auth_user:auth_pass123@auth-db:5432/auth_db")
|
||||
|
||||
# Redis settings
|
||||
REDIS_URL: str = os.getenv("REDIS_URL", "redis://redis:6379/0")
|
||||
# Redis Database (dedicated for auth)
|
||||
REDIS_DB: int = 0
|
||||
|
||||
# JWT settings
|
||||
JWT_SECRET_KEY: str = os.getenv("JWT_SECRET_KEY", "your-super-secret-jwt-key-change-in-production")
|
||||
JWT_ALGORITHM: str = os.getenv("JWT_ALGORITHM", "HS256")
|
||||
JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = int(os.getenv("JWT_ACCESS_TOKEN_EXPIRE_MINUTES", "30"))
|
||||
JWT_REFRESH_TOKEN_EXPIRE_DAYS: int = int(os.getenv("JWT_REFRESH_TOKEN_EXPIRE_DAYS", "7"))
|
||||
|
||||
# Password settings
|
||||
# Enhanced Password Requirements for Spain
|
||||
PASSWORD_MIN_LENGTH: int = 8
|
||||
PASSWORD_REQUIRE_UPPERCASE: bool = True
|
||||
PASSWORD_REQUIRE_LOWERCASE: bool = True
|
||||
PASSWORD_REQUIRE_NUMBERS: bool = True
|
||||
PASSWORD_REQUIRE_SYMBOLS: bool = False
|
||||
|
||||
# Security settings
|
||||
BCRYPT_ROUNDS: int = 12
|
||||
# Spanish GDPR Compliance
|
||||
GDPR_COMPLIANCE_ENABLED: bool = True
|
||||
DATA_RETENTION_DAYS: int = int(os.getenv("AUTH_DATA_RETENTION_DAYS", "365"))
|
||||
CONSENT_REQUIRED: bool = True
|
||||
PRIVACY_POLICY_URL: str = os.getenv("PRIVACY_POLICY_URL", "/privacy")
|
||||
|
||||
# Account Security
|
||||
ACCOUNT_LOCKOUT_ENABLED: bool = True
|
||||
MAX_LOGIN_ATTEMPTS: int = 5
|
||||
LOCKOUT_DURATION_MINUTES: int = 30
|
||||
PASSWORD_HISTORY_COUNT: int = 5
|
||||
|
||||
# RabbitMQ settings
|
||||
RABBITMQ_URL: str = os.getenv("RABBITMQ_URL", "amqp://bakery:forecast123@rabbitmq:5672/")
|
||||
# Session Management
|
||||
SESSION_TIMEOUT_MINUTES: int = int(os.getenv("SESSION_TIMEOUT_MINUTES", "60"))
|
||||
CONCURRENT_SESSIONS_LIMIT: int = int(os.getenv("CONCURRENT_SESSIONS_LIMIT", "3"))
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
# Email Verification
|
||||
EMAIL_VERIFICATION_REQUIRED: bool = os.getenv("EMAIL_VERIFICATION_REQUIRED", "true").lower() == "true"
|
||||
EMAIL_VERIFICATION_EXPIRE_HOURS: int = int(os.getenv("EMAIL_VERIFICATION_EXPIRE_HOURS", "24"))
|
||||
|
||||
settings = Settings()
|
||||
settings = AuthSettings()
|
||||
|
||||
Reference in New Issue
Block a user