From 21c42f887a54889e8cfd8998c67998ed9f3d8bb3 Mon Sep 17 00:00:00 2001 From: joshimai Date: Thu, 1 Aug 2024 13:18:45 -0400 Subject: [PATCH] remove development azurite keys --- README.md | 8 ++++++++ docker-compose.dev.yml | 14 ++++++++------ pc-funcs.dev.env | 11 +++++------ pccommon/pccommon/constants.py | 7 +++---- pcfuncs/tests/ipban/test_ipban.py | 5 +++-- scripts/bin/setup_azurite.py | 5 ++--- 6 files changed, 29 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index bbfef57c..30a7bbf3 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,14 @@ This project uses a variation on [scripts to rule them all](https://github.com/g #### Environment setup and building images +Before setting up the local environment, ensure that you have set the AZURITE_ACCOUNT_KEY environment variable. +The account key can be found in the [Azurite GitHub repository](https://github.com/Azure/Azurite?tab=readme-ov-file#usage-with-azure-storage-sdks-or-tools) + +For example, you can set the environment variable in your terminal with: +```console +> export AZURITE_ACCOUNT_KEY= +``` + To set up a local environment, use ```console diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 6204104d..db217ddd 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -18,19 +18,20 @@ services: - TILER_HREF=http://localhost:8080/data/ # Azure Storage + - AZURITE_ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY} - PCAPIS_COLLECTION_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1 - PCAPIS_COLLECTION_CONFIG__ACCOUNT_NAME=devstoreaccount1 - - PCAPIS_COLLECTION_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw== + - PCAPIS_COLLECTION_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY} - PCAPIS_COLLECTION_CONFIG__TABLE_NAME=collectionconfig - PCAPIS_CONTAINER_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1 - PCAPIS_CONTAINER_CONFIG__ACCOUNT_NAME=devstoreaccount1 - - PCAPIS_CONTAINER_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw== + - PCAPIS_CONTAINER_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY} - PCAPIS_CONTAINER_CONFIG__TABLE_NAME=containerconfig - PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1 - PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_NAME=devstoreaccount1 - - PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw== + - PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY} - PCAPIS_IP_EXCEPTION_CONFIG__TABLE_NAME=ipexceptionlist # Redis @@ -92,19 +93,20 @@ services: - WORKERS_PER_CORE=1 # Azure Storage + - AZURITE_ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY} - PCAPIS_COLLECTION_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1 - PCAPIS_COLLECTION_CONFIG__ACCOUNT_NAME=devstoreaccount1 - - PCAPIS_COLLECTION_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw== + - PCAPIS_COLLECTION_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY} - PCAPIS_COLLECTION_CONFIG__TABLE_NAME=collectionconfig - PCAPIS_CONTAINER_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1 - PCAPIS_CONTAINER_CONFIG__ACCOUNT_NAME=devstoreaccount1 - - PCAPIS_CONTAINER_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw== + - PCAPIS_CONTAINER_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY} - PCAPIS_CONTAINER_CONFIG__TABLE_NAME=containerconfig - PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1 - PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_NAME=devstoreaccount1 - - PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw== + - PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY} - PCAPIS_IP_EXCEPTION_CONFIG__TABLE_NAME=ipexceptionlist # Redis diff --git a/pc-funcs.dev.env b/pc-funcs.dev.env index 63b5f6ee..ea9c0dc9 100644 --- a/pc-funcs.dev.env +++ b/pc-funcs.dev.env @@ -1,16 +1,15 @@ -AzureWebJobsStorage=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1;QueueEndpoint=http://azurite:10001/devstoreaccount1;TableEndpoint=http://azurite:10002/devstoreaccount1; WEBSITE_HOSTNAME=funcs:8083 - ANIMATION_OUTPUT_STORAGE_URL="http://azurite:10000/devstoreaccount1/output/animations" -ANIMATION_OUTPUT_ACCOUNT_KEY="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" + ANIMATION_API_ROOT_URL="https://planetarycomputer-staging.microsoft.com/api/data/v1" ANIMATION_TILE_REQUEST_CONCURRENCY=2 IMAGE_OUTPUT_STORAGE_URL="http://azurite:10000/devstoreaccount1/output/images" -IMAGE_OUTPUT_ACCOUNT_KEY="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" + IMAGE_API_ROOT_URL="https://planetarycomputer-staging.microsoft.com/api/data/v1" IMAGE_TILE_REQUEST_CONCURRENCY=2 - STORAGE_ACCOUNT_URL=https://pctapisstagingsa.table.core.windows.net/ BANNED_IP_TABLE=blobstoragebannedip -LOG_ANALYTICS_WORKSPACE_ID=78d48390-b6bb-49a9-b7fd-a86f6522e9c4 \ No newline at end of file +LOG_ANALYTICS_WORKSPACE_ID=78d48390-b6bb-49a9-b7fd-a86f6522e9c4 + +AZURITE_ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY} \ No newline at end of file diff --git a/pccommon/pccommon/constants.py b/pccommon/pccommon/constants.py index 2a8a8d36..423c99ca 100644 --- a/pccommon/pccommon/constants.py +++ b/pccommon/pccommon/constants.py @@ -1,3 +1,5 @@ +import os + from opencensus.trace.attributes_helper import COMMON_ATTRIBUTES DEFAULT_COLLECTION_CONFIG_TABLE_NAME = "collectionconfig" @@ -34,7 +36,4 @@ # This is the Azurite storage account key. # This is not a key for a real Storage Account and is publicly accessible # on Azurite's GitHub repo. This is used only in development. -AZURITE_ACCOUNT_KEY = ( - "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUz" - "FT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" -) +AZURITE_ACCOUNT_KEY: str = os.environ.get("AZURITE_ACCOUNT_KEY", "") diff --git a/pcfuncs/tests/ipban/test_ipban.py b/pcfuncs/tests/ipban/test_ipban.py index 749c4fd7..f5c69f8c 100644 --- a/pcfuncs/tests/ipban/test_ipban.py +++ b/pcfuncs/tests/ipban/test_ipban.py @@ -13,6 +13,8 @@ from ipban.models import UpdateBannedIPTask from pytest_mock import MockerFixture +from pccommon.constants import AZURITE_ACCOUNT_KEY + MOCK_LOGS_QUERY_RESULT = [("192.168.1.1", 8000), ("192.168.1.4", 12000)] TEST_ID = str(uuid.uuid4()).replace("-", "") # dash is not allowed in table name TEST_BANNED_IP_TABLE = f"testblobstoragebannedip{TEST_ID}" @@ -58,8 +60,7 @@ def mock_clients( logs_query_client.query_workspace.return_value = mock_response CONNECTION_STRING: str = ( "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;" - "AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsu" - "Fq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;" + f"AccountKey={AZURITE_ACCOUNT_KEY};" "TableEndpoint=http://azurite:10002/devstoreaccount1;" ) diff --git a/scripts/bin/setup_azurite.py b/scripts/bin/setup_azurite.py index 7be14445..999823d0 100644 --- a/scripts/bin/setup_azurite.py +++ b/scripts/bin/setup_azurite.py @@ -14,6 +14,7 @@ from pccommon.config.collections import CollectionConfig, CollectionConfigTable from pccommon.config.containers import ContainerConfig, ContainerConfigTable from pccommon.constants import ( + AZURITE_ACCOUNT_KEY, DEFAULT_COLLECTION_CONFIG_TABLE_NAME, DEFAULT_CONTAINER_CONFIG_TABLE_NAME, DEFAULT_IP_EXCEPTION_CONFIG_TABLE_NAME, @@ -27,9 +28,7 @@ AZURITE_CONNECT_STRING = ( "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;" - "AccountKey=" - "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq" - "/K1SZFPTOtr/KBHBeksoGMGw==;" + f"AccountKey={AZURITE_ACCOUNT_KEY};" "BlobEndpoint=http://azurite:10000/devstoreaccount1;" "QueueEndpoint=http://azurite:10001/devstoreaccount1;" "TableEndpoint=http://azurite:10002/devstoreaccount1;"