diff --git a/app/config.py b/app/config.py index 88384d1ad0..3f28350200 100644 --- a/app/config.py +++ b/app/config.py @@ -233,8 +233,8 @@ class Config(object): SALESFORCE_USERNAME = os.getenv("SALESFORCE_USERNAME") SALESFORCE_PASSWORD = os.getenv("SALESFORCE_PASSWORD") SALESFORCE_SECURITY_TOKEN = os.getenv("SALESFORCE_SECURITY_TOKEN") - CRM_GITHUB_PERSONAL_ACCESS_TOKEN = os.getenv("CRM_GITHUB_PERSONAL_ACCESS_TOKEN") - CRM_ORG_LIST_URL = os.getenv("CRM_ORG_LIST_URL") + GC_ORGANISATIONS_BUCKET_NAME = os.getenv("GC_ORGANISATIONS_BUCKET_NAME") + GC_ORGANISATIONS_FILENAME = os.getenv("GC_ORGANISATIONS_FILENAME", "all.json") # Logging DEBUG = False @@ -748,9 +748,8 @@ class Test(Development): API_HOST_NAME = "http://localhost:6011" TEMPLATE_PREVIEW_API_HOST = "http://localhost:9999" - CRM_GITHUB_PERSONAL_ACCESS_TOKEN = "test-token" - CRM_ORG_LIST_URL = "https://test-url.com" FAILED_LOGIN_LIMIT = 0 + GC_ORGANISATIONS_BUCKET_NAME = "test-gc-organisations" class Production(Config): diff --git a/app/service/utils.py b/app/service/utils.py index 45cf4ed444..9e3bb36d34 100644 --- a/app/service/utils.py +++ b/app/service/utils.py @@ -2,7 +2,7 @@ import json from typing import Optional -import requests +from app.aws.s3 import get_s3_file from flask import current_app from notifications_utils.recipients import allowed_to_send_to from sqlalchemy.orm.exc import NoResultFound @@ -68,14 +68,13 @@ def safelisted_members(service, key_type, is_simulated=False, allow_safelisted_r def get_gc_organisation_data() -> list[dict]: - "Returns the dataset from the gc-organisations repo" - response = requests.get( - current_app.config["CRM_ORG_LIST_URL"], - headers={"Authorization": f'token {current_app.config["CRM_GITHUB_PERSONAL_ACCESS_TOKEN"]}'}, + "Returns the dataset from the gc-organisations repo, which we cache in s3" + file_data = get_s3_file( + current_app.config["GC_ORGANISATION_DATA_BUCKET_NAME"], + current_app.config["GC_ORGANISATIONS_FILENAME"], ) - response.raise_for_status() - account_data = json.loads(response.text) + account_data = json.loads(file_data) return account_data