import os as _jwt_os from pathlib import Path as _JwtPath def _read_secret_file(path): try: return _JwtPath(path).read_text().strip() except FileNotFoundError: return "" _jwt_has_private = bool(_jwt_os.environ.get("JWT_PRIVATE_KEY")) if not _jwt_has_private: _jwt_os.environ["JWT_PRIVATE_KEY"] = "" with open("/jwt-config/original-production.py") as _jwt_source: exec(compile(_jwt_source.read(), "/jwt-config/original-production.py", "exec"), globals()) if not _jwt_has_private: _jwt_os.environ.pop("JWT_PRIVATE_KEY", None) SIMPLE_JWT["SIGNING_KEY"] = "" if _jwt_os.environ.get("JWT_SIGNER_MODE") == "server": ROOT_URLCONF = "config.jwt_signer_urls" del _jwt_has_private, _jwt_source REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"] = [ "config.jwt_legacy_auth.VerifiedJWTStatelessUserAuthentication" if name == "core.auth.JWTStatelessUserAuthentication" else name for name in REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"] ]