From dce39a925fdf1cd708941f7fc3fa7486d94cd890 Mon Sep 17 00:00:00 2001 From: Tasha Upchurch Date: Fri, 8 Dec 2023 11:15:47 -0500 Subject: [PATCH] modified security to be optionally configured to be skipped for local connections. --- config.py | 15 +++++++++++++++ config.yaml | 1 + server_endpoints.py | 17 ++++++++++++++--- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 config.py create mode 100644 config.yaml diff --git a/config.py b/config.py new file mode 100644 index 0000000..d493efd --- /dev/null +++ b/config.py @@ -0,0 +1,15 @@ +import yaml + + +def read_yaml(file_path): + with open(file_path, 'r') as file: + data = yaml.safe_load(file) + return data + + +import os + +this_file_path = os.path.dirname(os.path.realpath(__file__)) +config_file_path = os.path.join(this_file_path, "config.yaml") +# Load the YAML data when the module is imported +config_settings = read_yaml(config_file_path) diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..7ef22c3 --- /dev/null +++ b/config.yaml @@ -0,0 +1 @@ +skip_login_for_local: true diff --git a/server_endpoints.py b/server_endpoints.py index 5c70233..2306d46 100644 --- a/server_endpoints.py +++ b/server_endpoints.py @@ -6,8 +6,8 @@ import logging import os from folder_paths import output_directory, input_directory, temp_directory from custom_nodes.EternalKernelLiteGraphNodes.local_shared import GDE_PATH, ETK_PATH +from .config import config_settings -from .update_js import check_for_js_extension fake_git = None real_git_url = "https://github.com/story-squad/GDE_Graph_IO.git" # is this actually an uri? @@ -343,7 +343,18 @@ def hijack_prompt_server(): # find in users by client_id user = await get_user_if_client_id_logged_in(client_id) - if user is None: + + if config_settings["skip_login_for_local"]: + peername = request.transport.get_extra_info('peername') + if peername is not None: + host, _ = peername + if host == '127.0.0.1' or host == '::1': + print("skipping login for local") + else: + print("user not found") + return web.json_response({"error": "user not found"}, status=401) + + elif user is None: print("user not found") return web.json_response({"error": "user not found"}, status=401) else: @@ -476,6 +487,6 @@ async def load_from_git(request): return web.json_response({"data": file_data}) -check_for_js_extension() + if __name__ != 'EternalKernelLiteGraphNodes.server_endpoints': hijack_prompt_server()