From a678076f637b29ea221d70bfe33fcb0cb85176eb Mon Sep 17 00:00:00 2001 From: Stefani <> Date: Tue, 22 Aug 2023 10:35:07 +0200 Subject: [PATCH 1/3] feat: enable basic auth through env --- src/prefect/client/orchestration.py | 6 ++++++ src/prefect/settings.py | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/prefect/client/orchestration.py b/src/prefect/client/orchestration.py index c11ff8d52b4c..93c888a4eba0 100644 --- a/src/prefect/client/orchestration.py +++ b/src/prefect/client/orchestration.py @@ -103,6 +103,7 @@ PREFECT_API_URL, PREFECT_CLOUD_API_URL, PREFECT_UNIT_TEST_MODE, + PREFECT_API_BASIC_AUTH ) from prefect.utilities.collections import AutoEnum @@ -142,6 +143,7 @@ def get_client(httpx_settings: Optional[dict] = None) -> "PrefectClient": return PrefectClient( api, api_key=PREFECT_API_KEY.value(), + api_basic_auth=PREFECT_API_BASIC_AUTH.value(), httpx_settings=httpx_settings, ) @@ -153,6 +155,7 @@ class PrefectClient: Args: api: the REST API URL or FastAPI application to connect to api_key: An optional API key for authentication. + api_basic_auth: An optional basic auth string for authentication. api_version: The API version this client is compatible with. httpx_settings: An optional dictionary of settings to pass to the underlying `httpx.AsyncClient` @@ -177,6 +180,7 @@ def __init__( api: Union[str, FastAPI], *, api_key: str = None, + api_basic_auth: str = None, api_version: str = None, httpx_settings: dict = None, ) -> None: @@ -194,6 +198,8 @@ def __init__( httpx_settings["headers"].setdefault("X-PREFECT-API-VERSION", api_version) if api_key: httpx_settings["headers"].setdefault("Authorization", f"Bearer {api_key}") + if api_basic_auth: + httpx_settings["headers"].setdefault("Authorization", f"Basic {api_basic_auth}") # Context management self._exit_stack = AsyncExitStack() diff --git a/src/prefect/settings.py b/src/prefect/settings.py index 4714223e10e8..7e324d43f508 100644 --- a/src/prefect/settings.py +++ b/src/prefect/settings.py @@ -589,6 +589,13 @@ def default_cloud_ui_url(settings, value): ) """API key used to authenticate with a the Prefect API. Defaults to `None`.""" +PREFECT_API_BASIC_AUTH = Setting( + str, + default=None, + is_secret=True, +) +"""BASIC Auth token to authenticate with a the Prefect API. Defaults to `None`.""" + PREFECT_API_ENABLE_HTTP2 = Setting(bool, default=True) """ If true, enable support for HTTP/2 for communicating with an API. From 9ffdc6e4c8c1db2c79c604306243e3212978d6b0 Mon Sep 17 00:00:00 2001 From: Stefani <> Date: Wed, 23 Aug 2023 11:36:31 +0200 Subject: [PATCH 2/3] feat: custom images build script --- scripts/build-images.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 scripts/build-images.sh diff --git a/scripts/build-images.sh b/scripts/build-images.sh new file mode 100755 index 000000000000..998c181ab69b --- /dev/null +++ b/scripts/build-images.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e + +VERSION=${VERSION} +ARCH=$(uname -m) +REPO="brigad/irdu-data/prefect/production" +ACCOUNT="227743832892.dkr.ecr.eu-west-1.amazonaws.com" +FULL_REPO="${ACCOUNT}/${REPO}" + +echo $FULL_REPO + +docker build -f ../Dockerfile .. -t ${FULL_REPO}:${VERSION}-${ARCH} + +docker push ${FULL_REPO}:${VERSION}-${ARCH} + +IMAGES=$(aws ecr list-images --repository-name ${REPO} |jq -c '.imageIds[] | select(has("imageTag") and (.imageTag | contains("2.11.4-"))) | .imageTag' | xargs -I% echo ${FULL_REPO}:% | xargs) + +echo ${IMAGES} + +docker manifest create ${FULL_REPO}:${VERSION} ${IMAGES} --amend + +docker manifest push ${FULL_REPO}:${VERSION} From 157df99253b3bb7f222f3a67849276709f6966c8 Mon Sep 17 00:00:00 2001 From: Stefani <> Date: Thu, 31 Aug 2023 15:51:52 +0200 Subject: [PATCH 3/3] fix: added python version forcing --- scripts/build-images.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-images.sh b/scripts/build-images.sh index 998c181ab69b..6dbcbe88fb2e 100755 --- a/scripts/build-images.sh +++ b/scripts/build-images.sh @@ -10,7 +10,7 @@ FULL_REPO="${ACCOUNT}/${REPO}" echo $FULL_REPO -docker build -f ../Dockerfile .. -t ${FULL_REPO}:${VERSION}-${ARCH} +docker build --build-arg PYTHON_VERSION=3.11 --build-arg BUILD_PYTHON_VERSION=3.11 -f ../Dockerfile .. -t ${FULL_REPO}:${VERSION}-${ARCH} docker push ${FULL_REPO}:${VERSION}-${ARCH}