From 331f279485c7f5bebfbfa5a9094dad8b30178efa Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 24 Apr 2024 15:50:49 -0400 Subject: [PATCH] added CONNECTOR_PROXY_USE_WERKZEUG_MIDDLEWARE_PROXY_FIX config option w/ burnettk --- app.py | 6 ++++++ config.py | 29 +++++++++++++++++++++++------ poetry.lock | 14 +++++++------- pyproject.toml | 1 + 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/app.py b/app.py index 60cb628..dd163e6 100644 --- a/app.py +++ b/app.py @@ -10,6 +10,12 @@ app.config.from_pyfile("config.py", silent=True) if app.config["ENV"] != "production": os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1" +if app.config["CONNECTOR_PROXY_USE_WERKZEUG_MIDDLEWARE_PROXY_FIX"]: + from werkzeug.middleware.proxy_fix import ProxyFix + + app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1) + + # Use the SpiffConnector Blueprint, which will auto-discover any # connector-* packages and provide API endpoints for listing and executing # available services. diff --git a/config.py b/config.py index 3213290..db754e1 100644 --- a/config.py +++ b/config.py @@ -1,14 +1,31 @@ from os import environ -CONNECTOR_PROXY_WAKU_BASE_URL = environ.get("CONNECTOR_PROXY_WAKU_BASE_URL", default="localhost") +CONNECTOR_PROXY_USE_WERKZEUG_MIDDLEWARE_PROXY_FIX = ( + environ.get("CONNECTOR_PROXY_USE_WERKZEUG_MIDDLEWARE_PROXY_FIX", default="false") + == "true" +) + +CONNECTOR_PROXY_WAKU_BASE_URL = environ.get( + "CONNECTOR_PROXY_WAKU_BASE_URL", default="localhost" +) CONNECTOR_PROXY_XERO_CLIENT_ID = environ.get("CONNECTOR_PROXY_XERO_CLIENT_ID") CONNECTOR_PROXY_XERO_CLIENT_SECRET = environ.get("CONNECTOR_PROXY_XERO_CLIENT_SECRET") -CONNECTOR_PROXY_POSTGRESQL_DB_NAME = environ.get("CONNECTOR_PROXY_POSTGRESQL_DB_NAME", default="spiffworkflow_secondary_storage_dev") -CONNECTOR_PROXY_POSTGRESQL_USER_NAME = environ.get("CONNECTOR_PROXY_POSTGRESQL_USER_NAME", default="postgres") -CONNECTOR_PROXY_POSTGRESQL_HOST = environ.get("CONNECTOR_PROXY_POSTGRESQL_HOST", default="localhost") -CONNECTOR_PROXY_POSTGRESQL_PORT = environ.get("CONNECTOR_PROXY_POSTGRESQL_PORT", default="7005") +CONNECTOR_PROXY_POSTGRESQL_DB_NAME = environ.get( + "CONNECTOR_PROXY_POSTGRESQL_DB_NAME", default="spiffworkflow_secondary_storage_dev" +) +CONNECTOR_PROXY_POSTGRESQL_USER_NAME = environ.get( + "CONNECTOR_PROXY_POSTGRESQL_USER_NAME", default="postgres" +) +CONNECTOR_PROXY_POSTGRESQL_HOST = environ.get( + "CONNECTOR_PROXY_POSTGRESQL_HOST", default="localhost" +) +CONNECTOR_PROXY_POSTGRESQL_PORT = environ.get( + "CONNECTOR_PROXY_POSTGRESQL_PORT", default="7005" +) CONNECTOR_PROXY_POSTGRESQL_PASSWORD = environ.get("CONNECTOR_PROXY_POSTGRESQL_PASSWORD") -SECRET_KEY = environ.get("FLASK_SESSION_SECRET_KEY", default="super-secret-key-for-flask") +SECRET_KEY = environ.get( + "FLASK_SESSION_SECRET_KEY", default="super-secret-key-for-flask" +) diff --git a/poetry.lock b/poetry.lock index 3a64b46..2957b3d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.1 and should not be changed by hand. [[package]] name = "alabaster" @@ -1662,20 +1662,20 @@ testing = ["coverage (>=6.2)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7 [[package]] name = "werkzeug" -version = "2.2.2" +version = "2.3.8" description = "The comprehensive WSGI web application library." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "Werkzeug-2.2.2-py3-none-any.whl", hash = "sha256:f979ab81f58d7318e064e99c4506445d60135ac5cd2e177a2de0089bfd4c9bd5"}, - {file = "Werkzeug-2.2.2.tar.gz", hash = "sha256:7ea2d48322cc7c0f8b3a215ed73eabd7b5d75d0b50e31ab006286ccff9e00b8f"}, + {file = "werkzeug-2.3.8-py3-none-any.whl", hash = "sha256:bba1f19f8ec89d4d607a3bd62f1904bd2e609472d93cd85e9d4e178f472c3748"}, + {file = "werkzeug-2.3.8.tar.gz", hash = "sha256:554b257c74bbeb7a0d254160a4f8ffe185243f52a52035060b761ca62d977f03"}, ] [package.dependencies] MarkupSafe = ">=2.1.1" [package.extras] -watchdog = ["watchdog"] +watchdog = ["watchdog (>=2.3)"] [[package]] name = "xdoctest" @@ -1731,4 +1731,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "6ecda3765e2bef8276efb92f4b0c5a4adf2fd805a8941ad8e14d631b370a62cf" +content-hash = "5ba64798d033352d864798bcbfb54af364eab1b603696879e52bac81753270bf" diff --git a/pyproject.toml b/pyproject.toml index bb63a9f..f9fa26d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ Flask-Session = "^0.4.0" types-requests = "^2.28.11.2" simplejson = "^3.17.6" spiffworkflow-proxy = {git = "https://github.com/sartography/spiffworkflow-proxy"} +werkzeug = "^2.3" [tool.poetry.dev-dependencies]