def make_broadcast_url(): BROADCAST_USER = "" BROADCAST_DRIVER = getenv("BROADCAST_DRIVER") BROADCAST_PATH = getenv("BROADCAST_PATH") BROADCAST_HOST = getenv("BROADCAST_HOST") BROADCAST_PASSWORD = getenv("BROADCAST_PASSWORD") BROADCAST_URL = f"{BROADCAST_DRIVER}://{BROADCAST_USER}:{BROADCAST_PASSWORD}@{BROADCAST_HOST}/{BROADCAST_PATH}" return BROADCAST_URL
def make_broadcast_url(): BROADCAST_USER = "" BROADCAST_DRIVER = getenv("BROADCAST_DRIVER", "redis") BROADCAST_PATH = getenv("BROADCAST_PATH", "0") BROADCAST_HOST = getenv("BROADCAST_HOST", "broadcast") BROADCAST_PORT = getenv("BROADCAST_PORT", "6379") BROADCAST_PASSWORD = getenv("BROADCAST_PASSWORD", "broadcast") BROADCAST_URL = f"{BROADCAST_DRIVER}://{BROADCAST_USER}:{BROADCAST_PASSWORD}@{BROADCAST_HOST}:{BROADCAST_PORT}/{BROADCAST_PATH}" return BROADCAST_URL
def make_db_url(): DB_DRIVER = getenv("DB_DRIVER") DB_DATABASE = getenv("DB_DATABASE") if "sqlite" in DB_DRIVER: SQLALCHEMY_DATABASE_URI = f"{DB_DRIVER}:///{DB_DATABASE}" else: DB_SERVER = getenv("DB_HOST") DB_USER = getenv("DB_USER") DB_PASSWORD = getenv("DB_PASSWORD") SQLALCHEMY_DATABASE_URI = ( f"{DB_DRIVER}://{DB_USER}:{DB_PASSWORD}@{DB_SERVER}/{DB_DATABASE}" ) return SQLALCHEMY_DATABASE_URI
def make_db_url(): DB_DRIVER = getenv("DB_DRIVER", "postgresql") DB_DATABASE = getenv("DB_DATABASE", "postgres") if "sqlite" in DB_DRIVER: SQLALCHEMY_DATABASE_URI = f"{DB_DRIVER}:///{DB_DATABASE}" else: DB_SERVER = getenv("DB_HOST", "db") DB_USER = getenv("DB_USER", "postgres") DB_PASSWORD = getenv("DB_PASSWORD", "postgres") DB_PORT = getenv("DB_PORT", "5432") SQLALCHEMY_DATABASE_URI = ( f"{DB_DRIVER}://{DB_USER}:{DB_PASSWORD}@{DB_SERVER}:{DB_PORT}/{DB_DATABASE}" ) return SQLALCHEMY_DATABASE_URI
import os from base64 import b64encode from bountydns.core.utils import getenv_bool, getenv from bountydns.db.session import db_url API_V1_STR = "/api/v1" API_SERVER_HOST = getenv("API_SERVER_HOST") API_SECRET_KEY = getenv("API_SECRET_KEY") JWT_ALGORITHM = "HS256" if not API_SECRET_KEY: API_SECRET_KEY = b64encode(os.urandom(32)).decode("utf-8") ACCESS_TOKEN_EXPIRE_MINUTES = 60 * 24 * 8 # 60 minutes * 24 hours * 8 days = 8 days API_CORS_ORIGINS = getenv( "API_CORS_ORIGINS" ) # a string of origins separated by commas, e.g: "http://localhost, http://localhost:4200, http://localhost:3000, http://localhost:8080, http://local.dockertoolbox.tiangolo.com" API_PROJECT_NAME = getenv("API_PROJECT_NAME", "Bounty DNS") SQLALCHEMY_DATABASE_URI = db_url() API_SUPERUSER_EMAIL = getenv("API_SUPERUSER_EMAIL", optional=True) API_SUPERUSER_PASSWORD = getenv("API_SUPERUSER_PASSWORD", optional=True) API_SUPERUSER_MFA_SECRET = getenv("API_SUPERUSER_MFA_SECRET", optional=True)
def get_resolved_db_path(): DB_DATABASE = getenv("DB_DATABASE", "", optional=True) # null for in memory db return resolve_db_path(DB_DATABASE)