Files
Star-Office-UI/backend/security_utils.py
T

35 lines
819 B
Python

#!/usr/bin/env python3
"""Security helper utilities for Star Office backend.
P1 step: extraction without behavior change.
"""
from __future__ import annotations
import os
def is_production_mode() -> bool:
env = (os.getenv("STAR_OFFICE_ENV") or os.getenv("FLASK_ENV") or "").strip().lower()
return env in {"prod", "production"}
def is_strong_secret(secret: str) -> bool:
if not secret:
return False
secret = secret.strip()
if len(secret) < 24:
return False
weak_markers = {"change-me", "dev", "example", "test", "default"}
low = secret.lower()
return not any(m in low for m in weak_markers)
def is_strong_drawer_pass(pwd: str) -> bool:
if not pwd:
return False
pwd = pwd.strip()
if pwd == "1234":
return False
return len(pwd) >= 8