17 lines
425 B
Python
17 lines
425 B
Python
import os
|
|
from pathlib import Path
|
|
|
|
|
|
def secret(name):
|
|
value = Path(os.environ[name]).read_text(encoding="utf-8").strip()
|
|
if not value:
|
|
raise ValueError(f"Empty secret file: {name}")
|
|
return value
|
|
|
|
|
|
def session_ttl():
|
|
value = int(os.environ.get("SESSION_TTL_SECONDS", "3600"))
|
|
if not 1 <= value <= 86400:
|
|
raise ValueError("SESSION_TTL_SECONDS must be between 1 and 86400")
|
|
return value
|