Skip to content

Commit

Permalink
Merge pull request #32 from CanDIG/daisieh/ingest
Browse files Browse the repository at this point in the history
Read in db password from secrets file
  • Loading branch information
daisieh authored Nov 11, 2021
2 parents 0b83be6 + 6925a3b commit 6718925
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions chord_metadata_service/metadata/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

POSTGRES_PASSWORD_FILE = os.environ.get('POSTGRES_PASSWORD_FILE')
if POSTGRES_PASSWORD_FILE is not None:
with open(os.environ.get('POSTGRES_PASSWORD_FILE'), "r") as f:
POSTGRES_PASSWORD_FILE = f.read()

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
Expand Down Expand Up @@ -55,7 +58,7 @@
# Allowed hosts - TODO: Derive from CHORD_URL

CHORD_HOST = urlparse(CHORD_URL or "").netloc
ALLOWED_HOSTS = [CHORD_HOST or "localhost"]
ALLOWED_HOSTS = ["*"] # we'll determine access via middleware before we get here
if DEBUG:
ALLOWED_HOSTS = list(set(ALLOWED_HOSTS + ["localhost", "127.0.0.1", "[::1]"]))

Expand Down Expand Up @@ -185,7 +188,7 @@
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get("POSTGRES_DATABASE", 'metadata'),
'USER': os.environ.get("POSTGRES_USER", 'admin'),
'PASSWORD': os.environ.get("POSTGRES_PASSWORD", 'admin'),
'PASSWORD': os.environ.get("POSTGRES_PASSWORD", POSTGRES_PASSWORD_FILE),

# Use sockets if we're inside a CHORD container / as a priority
'HOST': os.environ.get("POSTGRES_SOCKET_DIR", os.environ.get("POSTGRES_HOST", "localhost")),
Expand Down

0 comments on commit 6718925

Please sign in to comment.