ollama-auth-v2 / config.py
Amaranath's picture
Create config.py
253f4ad verified
import os
import secrets
from typing import Optional
class Settings:
def __init__(self):
# Generate a secure API key if not provided
self.api_key: str = os.getenv("API_KEY", secrets.token_urlsafe(32))
# Generate a separate admin key for sensitive operations
self.admin_key: str = os.getenv("ADMIN_KEY", secrets.token_urlsafe(32))
self.ollama_host: str = os.getenv("OLLAMA_HOST", "127.0.0.1:11434")
self.app_host: str = os.getenv("APP_HOST", "0.0.0.0")
self.app_port: int = int(os.getenv("APP_PORT", "7860"))
# Print both keys for easy access
print("=" * 60)
print("πŸ”‘ AUTHENTICATION KEYS")
print("=" * 60)
print(f"πŸ” API Key (for regular usage): {self.api_key}")
print(f"πŸ”§ Admin Key (for key management): {self.admin_key}")
print("=" * 60)
print("🚨 SAVE BOTH KEYS SECURELY!")
print("πŸ” API Key: Use for all model operations")
print("πŸ”§ Admin Key: Use for key management and admin operations")
print("=" * 60)
settings = Settings()