diff --git a/src/webqueue2api/__init__.py b/src/webqueue2api/__init__.py index ba7b477..96c62be 100644 --- a/src/webqueue2api/__init__.py +++ b/src/webqueue2api/__init__.py @@ -1,2 +1,22 @@ from webqueue2api.parser import Item, Queue, load_queues -from .config import config \ No newline at end of file +import configparser, sys +from pathlib import Path +from .config import config + +config_parser = configparser.ConfigParser() +config_file_path = Path.joinpath(Path(sys.executable).parent.parent.parent, "webqueue2api_config.ini") + +if Path(config_file_path).exists(): + config_parser.read(config_file_path) + + if config_parser.has_section("parser"): + if config_parser.has_option("parser", "queue_directory"): + config.parser.queue_directory = config_parser["parser"]["queue_directory"] + if config_parser.has_option("parser", "queues_to_ignore"): + config.parser.queues_to_ignore = config_parser["parser"]["queues_to_ignore"] + + if config_parser.has_section("api"): + if config_parser.has_option("api", "environment"): + config.api.environment = config_parser["api"]["environment"] + if config_parser.has_option("api", "jwt_secret_key"): + config.api.jwt_secret_key = config_parser["api"]["jwt_secret_key"] \ No newline at end of file diff --git a/src/webqueue2api/api/app.py b/src/webqueue2api/api/app.py index 99282be..477ce50 100644 --- a/src/webqueue2api/api/app.py +++ b/src/webqueue2api/api/app.py @@ -19,7 +19,7 @@ # Look for JWTs in headers (for access) then cookies (for refresh) app.config["JWT_TOKEN_LOCATION"] = ["headers", "cookies"] # Restrict cookies to HTTPS in prod, allow HTTP in dev -app.config["JWT_COOKIE_SECURE"] = False if config.jwt_secret_key == "dev" else True +app.config["JWT_COOKIE_SECURE"] = False if config.environment == "dev" else True # Restrict cookies using SameSite=strict flag app.config["JWT_COOKIE_SAMESITE"] = "strict" # Restrict refresh tokens to /token/refresh endpoint