From ea9a732803b0aa086eb5abc9daaf27dddc918c46 Mon Sep 17 00:00:00 2001 From: Ojakoo Date: Wed, 17 Aug 2022 23:00:11 +0300 Subject: [PATCH] Modified paths --- .env.sample | 2 +- production_entrypoint.sh | 4 ++-- sikweb/settings.py | 4 ++-- stack-compose.yml | 8 ++++---- webapp/utils.py | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.env.sample b/.env.sample index 1dcf8b6..7cc953c 100644 --- a/.env.sample +++ b/.env.sample @@ -10,4 +10,4 @@ DB_HOST=db DB_PORT=5432 EMAIL_API_KEY= GROUP_KEY= -GOOGLE_CREDS_JSON='{}' +GOOGLE_CREDS='{}' diff --git a/production_entrypoint.sh b/production_entrypoint.sh index c39f2f1..1415f92 100755 --- a/production_entrypoint.sh +++ b/production_entrypoint.sh @@ -10,8 +10,8 @@ fi if test -f "$DB_PASSWD_FILE"; then export DB_PASSWD=$(cat $DB_PASSWD_FILE) fi -if test -f "$GOOGLE_CREDS_JSON"; then - export GOOGLE_CREDS_JSON=$(cat $GOOGLE_CRED_JSON_FILE) +if test -f "$GOOGLE_CREDS_FILE"; then + export GOOGLE_CREDS=$(cat $GOOGLE_CREDS_FILE) fi # Collect static files diff --git a/sikweb/settings.py b/sikweb/settings.py index cad33de..87a5e69 100644 --- a/sikweb/settings.py +++ b/sikweb/settings.py @@ -83,9 +83,9 @@ DATABASES = { # Google api settings GROUP_KEY = os.getenv("GROUP_KEY", "") try: - GOOGLE_SERVICE_ACCOUNT = json.loads(os.getenv("GOOGLE_CREDS_JSON", "{}")) + GOOGLE_CREDS_JSON = json.loads(os.getenv("GOOGLE_CREDS", "{}")) except: - GOOGLE_SERVICE_ACCOUNT = json.loads("{}") + GOOGLE_CREDS_JSON = json.loads("{}") # JWT authentication diff --git a/stack-compose.yml b/stack-compose.yml index 1165a2e..d780df1 100644 --- a/stack-compose.yml +++ b/stack-compose.yml @@ -34,14 +34,14 @@ services: - SECRET_KEY_FILE=/run/secrets/BACKEND_SECRET_KEY - DB_PASSWD_FILE=/run/secrets/BACKEND_DB_PASSWD - EMAIL_API_KEY_FILE=/run/secrets/BACKEND_EMAIL_API_KEY - - GOOGLE_CREDS_JSON=/run/secrets/GOOGLE_CREDS_JSON + - GOOGLE_CREDS_FILE=/run/secrets/BACKEND_GOOGLE_CREDS secrets: - BACKEND_SECRET_KEY - BACKEND_DB_PASSWD - BACKEND_EMAIL_API_KEY - - GOOGLE_CREDS_JSON - + - BACKEND_GOOGLE_CREDS + secrets: BACKEND_SECRET_KEY: external: true @@ -49,5 +49,5 @@ secrets: external: true BACKEND_EMAIL_API_KEY: external: true - GOOGLE_CREDS_JSON: + BACKEND_GOOGLE_CREDS: external: true diff --git a/webapp/utils.py b/webapp/utils.py index 6f696c7..d79446c 100644 --- a/webapp/utils.py +++ b/webapp/utils.py @@ -25,7 +25,7 @@ from sikweb.settings import ( DEFAULT_EMAIL_FROM_ADDR, ENABLE_AUTOMATIC_EMAILS, GROUP_KEY, - GOOGLE_SERVICE_ACCOUNT, + GOOGLE_CREDS_JSON, ) from datetime import timedelta @@ -136,7 +136,7 @@ def add_to_mailinglist(email: str): # create credentials, with subject is used to impersonate admin account # jas_manager has groups editor rights in google admin credentials = service_account.Credentials.from_service_account_info( - info=GOOGLE_SERVICE_ACCOUNT, scopes=SCOPES + info=GOOGLE_CREDS_JSON, scopes=SCOPES ).with_subject("jas_manager@sahkoinsinoorikilta.fi") service = build("admin", "directory_v1", credentials=credentials)